Array List Of Pizza Toppings - Access Cost Through Get And Set Method?
Dec 1, 2014
So I have created a array list of pizza toppings, only 4 in total, and each ingredient needs to have a cost property. I'm supposed to access the cost through a get / set method, as the user can create their own pizza and it will total up the cost, but how to.
View Replies
ADVERTISEMENT
Oct 9, 2014
I'm trying to write a program that will output the total number of large,medium,and small pizza along with the average cost of an order. I'm stuck on this error , "Else without if" on line 48 else ...medium.
import java.util.Scanner;
public class PizzaOrder
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in);
double cost,total, average;
String name,response,size,type;
int count,l,m,s;
[code]....
View Replies
View Related
Dec 2, 2014
I need to add from what is selected in some check boxes to an array that is in another class, but I can't get the other class to be called correctly.
I need to get the toppings that are selected from the check boxes added into the array that is in the calculations method.
Calculations method
Java Code:
import java.util.ArrayList;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
[Code] .....
View Replies
View Related
Mar 16, 2015
HTML Code:
import java.util.Scanner;
public class BellmanFord {
private int distances[];
private int numberofvertices;
public static final int MAX_VALUE = 999;
[Code] ....
I am trying to display two types of table one with initial cost and another one with new cost. Based on the java code here i already have one table but don't know how to display another table.
Attached is the sample output that i am aiming for. The output table for the above code is:
Enter the number of vertices
6
Enter the adjacency matrix
0 4 0 0 -1 0
0 0 -1 0 -2 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 -5 0 3
0 0 0 0 0 0
Enter the source vertex
1
distance of source 1 to 1 is 0
distance of source 1 to 2 is 4
distance of source 1 to 3 is 3
distance of source 1 to 4 is -6
distance of source 1 to 5 is -1
distance of source 1 to 6 is 2
View Replies
View Related
Mar 28, 2014
I had to write a program that prompts the cashier to enter all prices and names, adds them to two arrays lists, calls the method that I implemented, and displays the result and use 0 as the sentinel value. I am having difficulty coming up with a for loop in the method, I believe I have the condition right but I am having trouble with the statements. I now know that String does not have the get property, but I have only done examples with integers and I am not very good with for loops and wouldn't know how to fix it.
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
ArrayList<Double> sales = new ArrayList<Double>();
ArrayList<String> names = new ArrayList<String>();
System.out.print("Enter Number of Customers");
double salesAmount;
System.out.print("Enter Sales for First Customers");
salesAmount = in.nextDouble();
while(salesAmount != 0)
[code]....
View Replies
View Related
Jan 27, 2015
Write the following method that shuffles an array list of numbers.
public static void shuffle(ArrayList<Number> list)
package shuffleArrayList;
import java.util.ArrayList;
import java.util.Arrays;
public class ShuffleArrayList
{
public static void main(String[] args)
[code]....
View Replies
View Related
Oct 13, 2014
I am having a little trouble with a part of my Java assignment that needs to have linked lists in it.
I need to write a public method that takes an array of type object to load strings into a linked list.
View Replies
View Related
Apr 3, 2014
How we can get the list of records from database my sql using jsp pages and servlets so that it show results on webpage.
View Replies
View Related
Apr 8, 2014
We were suppose to make a program for an assignment and the prof provided some codes to start of. What does this basically mean? How do i access the string arrays from consolelist?
class ConsoleInfo {
private String conTitle;
private double conPrice;
private int conQty;
private String conPic;
private static String empPassword;
ConsoleInfo(String title, double price, int qty,String pic)
[Code]...
View Replies
View Related
Oct 18, 2014
I basically need to allow the user to add or remove toppings on the pizza once it is created. I am new to code (steps included). We are supposed to use enums and sets.
package pizza;
public class Pizza {
// Declare enums
public enum Size{
SMALL,
MEDIUM,
LARGE,
JUMBO
[code]....
I started this this is what I have currently I have an error here:
private Set<Topping> setOfToppings = new EnumSet<Topping>(Topping.class);
I am sure it is because I haven't set it up correctly.
View Replies
View Related
Dec 3, 2014
I've got the layout put correctly but I can't seem to get my action listeners to work correctly.
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class PizzaOrderDriver
{
public static void main(String[] args)
{
JCheckBox show1;
[Code] .....
View Replies
View Related
Feb 1, 2014
I am trying to make a program where a ball moves up continuously when you press space, then begins to move down when you reach a certain point. My method for this is to have a timer, and have a method that does this: When you press space, add 10 y coords every second (using a timer), and if you reach 470 y, then begin to drop 10 y coords. I made a method to hold the keylistener, and am running that method inside the actionPerformed method which is within another class. However, since it is a method, I cannot add my keylistener to my frame in the main method.
main
error line 9
Java Code: import javax.swing.*;
public class Main {
[code]...
View Replies
View Related
Jul 31, 2014
This is my code for a Pizza Pickup and delivery I am am having a few issues.
public class Internal {
public static void main(String[]args) {
double total2 = 0;
String customerName = " ";
String address = " ";
String phoneNum ="0";
[Code] ....
View Replies
View Related
Jul 26, 2014
I am making a pizza program and most of the program works. I have made an order button that will output the total price of the order. The reset button that I made makes the JTextArea output $0.00, but if I press the order button to make another order, the program does not add the new amount to zero. For example, if I make an order that totals $5.00, but I want to make another order after resetting, the price for the new order will be added on to the previous order's price.
Here is the code. This is a JApplet program. Why the price will not reset? This code was made in BlueJ.
//Author:Kishan Patel
// Sources will be cited soon.
//This is Lab 7, the pizza parlour program.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
[code]....
View Replies
View Related
Feb 1, 2015
Why is it that a protected method cannot be accessed polymorphically outside its package. I suspect the reason is that some compile-time checks have to be performed. Is this correct?
View Replies
View Related
Sep 16, 2014
I have 2 classes. TestClassA has 1 getter and 1 setter. From my second class, TestClassB, I want to access the getter method of TestClassA. If I try to access it, I get null. How do I do it?I do not want the methods to be declared as static. How can the getter method value be printed in TestClassB (without marking anything as static)?
public class TestA {
private String name;
public String getName() {
return name;
[code]....
View Replies
View Related
Feb 12, 2015
Why can't I access a method from another class? For example, I want to get the value of get method from another class. It's giving me an error on if(getExamType() == 'M') That's what I've done, for example:
Java Code:
public static Exam[] collateExams(Exam[] exams){
Exam [] r = new Exam[50];
r = exams;
Exam [] finalExam = new Exam[50];
for(int i = 0; i < r.length; i++) {
if(getExamType() == 'M') {
}
}
return r; mh_sh_highlight_all('java');
View Replies
View Related
Feb 9, 2014
This time I have to make a Black Jack game ( I guess this is a classic) I have created Three classes for this BlackJack( Main), Card, and Player.
What I am trying to do is put the Give one card to the player and remove it from the deck into a separate procedure because I will be doing this several times during the game.
This is the code I have so far Under the class BlackJack.
Java Code:
package black.jack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
[Code] .....
View Replies
View Related
Jun 3, 2014
I have a hyperlink say,
[URL]
now, i want to access a managed bean's method to execute a service call related to the code embedded in the hyperlink.
My Managed bean
@ManagedBean(name="details")
@SessionScoped
public class XXXX extends Bean implements Serializable{
public XXXX(){...... }
public myMethod(..){
service.getDataRelatedToHyperlinkCode(....passing code here to fetch details from DB)
}
}
if i use postConstruct annotation it is getting executed only once since it is a session scope. and point to be noted is i cannot use viewscope and requestscope.
View Replies
View Related
May 13, 2014
I am trying to assess a method which is public from servlet. but it gives weird error. image has been attached .....
View Replies
View Related
Feb 19, 2014
how to get an access to the method with a parameter of class type variable, lets say: public void insert(Record newRecord, int pos)?
View Replies
View Related
Jan 10, 2010
I've got a CDI bean which is a facade for a JPA entity. Such entity has got a many to one relationship with itself and I've got the following method:
public Set<Account> getChildren() {
return this.children;
}
which is called in a JSF/Facelets page:
<h:commandLink action="#{accountController.destroy}" value="#{bundle.ListAccountDestroyLink}" rendered="#{item.children.size() == 0}"/>I then decided to return an unmodifiable set and changed getChildren() accordingly:
public Set<Account> getChildren() {
return Collections.unmodifiableSet(children);
}
The page now reports this error:
java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
at java.lang.reflect.Method.invoke(Method.java:588)
[Code] ....
javax.el.BeanELResolver is incorrectly failing because it's trying to invoke the size() method using reflection without correctly taking into account the method visibility (which is indeed invokable programmatically). I'm running NetBeans 6.8, Glassfish 3.0 and jdk1.6.0_17.
Is this a bug in BeanELResolver?
View Replies
View Related
Apr 23, 2014
I want to keep count of how many students are in my array. the array i made up of objects from other classes. like the class Student how do i do this. i have tried contains but better way it to to a loop to go through the array and determine if each object is a particular type but i don't know how to do this. here is the code
import java.util.*;
import java.util.ArrayList;
public class Driver {
public static void main(String[] args){
/* Comments required
PersonFileReader pfr = new PersonFileReader("person.dat");
ArrayList<Person> testData = pfr.readData();
Database db = new Database(testData);
[Code] .....
View Replies
View Related
Jun 13, 2014
Now I am trying to print the 4 string randomly from string array..where string contains no of words which are splitted from the file....
View Replies
View Related
Jul 12, 2014
I have written following code.
I want to print all elements in Array to output here is my code
int[][] arr={{12,12,13},
{14,1223,14}};
for(int i=0;i<arr.length;i++)
{
for(int j=0;j<arr.length;j++)
{
System.out.println(arr[i][j]);
}
}
but I am getting following output
12
12
14
1223
how to print all elements of int array?
View Replies
View Related
Sep 21, 2014
Right, so I got this method that creates and sorts 2 lists. What I want to do is merge these lists into a third list, have it sorted, and then print the contents of the list. The problem is, I'm tired and I don't remember how I can print it.
import java.util.*;
public class MergeTwoSortedListWilson {
public void CHANGEME() {
// To do
ArrayList<String> aList = new ArrayList<String>();
aList.add("Banana");
[Code] ...
MergeTwoSortedListWilson.java:35: error: cannot find symbol
System.out.println(aList);
^
symbol: variable aList
location: class MergeTwoSortedListWilson
1 error
View Replies
View Related