Create Set - Allow User To Add Or Remove Toppings
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
ADVERTISEMENT
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
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
View Related
Oct 5, 2014
I'm having some difficulty with my bank account project. I'm supposed to create a menu where the user can create a new account, withdraw, deposit, view their balance, and exit. There's issues with the account creation.
Here's my necessitated class below: BankAccount, TestBankAccount, SavingsAccount, CurrentAccount, and Bank
/*---------------------------------------------------
Plagiarism Statement
I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons.
----------------------------------------------------------*/
package BankAccount;
import java.util.Date;
import java.util.Random;
//Project 3
public class BankAccount {
protected static int accountID;
[code]....
View Replies
View Related
Jan 28, 2014
I have a textField in which I have text in. The text is enter customer name. I would like for this text to disappear whenever the user clicks on the textField to enter a customer name. I am using the automated swing gui builder in NetBeans. Is their some sort of feature for this under properties of the text field? If not then what are my other options?
View Replies
View Related
Sep 16, 2014
Okay, so I know how to get user input and create a variable from the input, create a basic addition sum etc...
So I have this code:
package calc;
import java.util.Scanner;
class calc{
private static final double add = 0;
private static final double subtract = 0;
public static void main(String args[]){
[Code] .....
I'm basically trying to make it so that when the user enters tnum, tnum2, tnum3 and tnum4, their answer turns to the variable which has to be either true or false to make the boolean work. I don't know really how to do this. I want to make it so that if they enter yes, then that makes the boolean true and the numbers will multiply and create the answer variable. If they enter no then the boolean is false and it moves onto the next if statement. How can I do this?
View Replies
View Related
Mar 3, 2014
i need to create a program that asks the user for an array and then asks the user to fill in the slots of the array but i have to do it in a method
View Replies
View Related
Oct 13, 2014
so I had to create a program that allows the user to enter a day using a number and then enter a year and after they did that it would create an entire calendar for that year ..so I have that but the only issue is I can not get the numbers to line up neatly.how to do the entire thing in loops, I tried a couple in here..what this would look like as loops instead of switches and cases and if else
import java.util.Scanner;
public class Calendar {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
[code]....
View Replies
View Related
Sep 17, 2014
I am new to Java an have to Create a program that keeps track of the following information input by the user: First Name, Last Name, Phone Number, and Age. Now - let's store this in a multidimensional array that will hold 10 of these contacts. So our multidimensional array will need to be 10 rows and 4 columns.You should be able to add and remove contacts in the array.
View Replies
View Related
Sep 16, 2014
I am required to read user input to create two matrices which will eventually be added together. I am unsure as to how I can read the input from the user as an int and not a String. The input is from size 0-10 for both column and row size. Also, can you have a new button created in the actionPerformed method of a previous button?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class Matrices implements ActionListener {
private JFrame win1, win2, win3, win4;
[Code]...
View Replies
View Related
Jun 25, 2014
I have a database containing products which are separated in categories and subcategories.I want to create a user interface that will allow the customer to select any category or subcategory and load the products in the main application window.My problem is that i dont like tree do you know any alternative of tree that i can use ?
View Replies
View Related
Feb 17, 2015
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class App {
public static void main(String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please Select an option > ");
[Code] .....
View Replies
View Related
Mar 3, 2015
I am trying to create a basic graphical user interface for sequence translation (including a JTextField for the description of a sequence and status of function button pressed e.g. “simple” translation and input and output TextFields). This involves a number of different class files. I cannot get my user interface to do what I want and I think I have problems with my "actionPerformed" method. How the code should be linked together?
public void actionPerformed(ActionEvent event) {
try {
// Get the description, content and result
String d = tool.getDescription();
String input = tool.getInputText();
Stringr = translation.getResult();
[code]....
View Replies
View Related
Apr 14, 2014
I am new a creating GUIs and am not quite sure how to correctly make one. I have done the inheritance parts, and created two extra appliances: a washer and dryer. Now Creating the GUI ....
Here are the instructions to my project.
Introduction to GUIs (+ some inheritance)
For this assignment, you are going to create a user interface that interacts with the setters and getters of some classes that you will create.
First, create an abstract class called Appliance. This abstract class should have two attributes (dealing with household appliances) and two abstract methods called turnOn() and turnOff(). These methods should return void.
Then, create two subclasses of Appliance that represent household appliances (like a Refrigerator or Stove ((don't use those!))). These subclasses should have two attributes that are specific to the various appliance. Each subclass should implement the turnOn() and turnOff() methods. These methods should print to the command line some information about the appliance as it turns on and off.
Now, the fun part! Create a GUI interface!
Your window should have two panels: one for each appliance subclass. Each panel should have 4 textboxes (with appropriate labels) to receive/display information that correspond to the 4 attributes (2 from Appliance and 2 from the subclass) for each subclass.You also need 2 buttons on each panel: A Get button and a Set button.
When the Get button is pressed, the text boxes should be filled with the information from the instantiated object of the appropriate subclass. When the Set button is pressed, the object should then contain the information contained that the user has altered.
In your main method, you should create an object of each subclass, and prefill it with information (either using the constructor or the setters), then display your GUI. You should now be able to get and set the information for your objects from the GUI.
At least one of your attributes for each subclass should be numeric
Note that you will need to handle incorrectly formatted input (You can use exception handling to do this if you want to. Wrapper classes also will work)
If there is text in the boxes when the "Get" button is pressed, it should be overwritten by what is in the object. Remember that these two panels should both be on screen at the same time.
You don't need 2 different windows, one window: 2 panels.
View Replies
View Related
Jun 6, 2014
So I'm trying to create a simple user database that I could eventually turn into a login system. I created a simple table on MySQL with a name and address for the sake of simplicity. I tried to create simple statement inside my main method that would connect to my MySQL server and when I run my program I get a ClassNotFoundException from "org.gjt.mm.mysql.Driver"..Here is what I have in my main method thus far:
public static void main(String args[]) {
try {
Class.forName("org.gjt.mm.mysql.Driver"); //Load the driver
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/data", "root", ""); //Connect
/*
conn.createStatement().execute("CREATE TABLE people (" + "id int(64) NOT NULL AUTO_INCREMENT," + "name varchar(255) NOT NULL," + "address varchar(255) NOT NULL," + "UNIQUE (id)," + "FULLTEXT(name, address))");
[code]....
I downloaded Connector/J in the the binary .zip form and extracted it to my C: drive and put the .jar file into my java directories lib folder. I also added the directory of the .jar file into my CLASSPATH and I still get the exception.
View Replies
View Related
Mar 15, 2014
1. creates a file.
2. ask user to write into that file
3. save the file
4. print content of file.
Is my current exercise, so far i have gotten the code to create a file. What should i use to ask user to write into that file and save?
package assignment7;
import java.io.*;
public class Exercise2
{
public static void main ( String [ ] args ) {
String filePath="newfile.txt";
File newFile = new File ( filePath ) ;
[Code] .....
View Replies
View Related
Mar 17, 2014
1. creates a file.
2. ask user to write into that file
3. save the file
4. print content of file.
is my current exercise.so far i have gotten the code to create a file, and ask the user to input their age.what should i use to save what the user writes into the file?
Java Code:
package assignment7;
import java.io.*;
import java.util.*;
public class Exercise2
{
public static void main ( String [ ] args ) throws IOException
{
Scanner scan = new Scanner(System.in);
[code]....
View Replies
View Related
Mar 9, 2015
I am new to java and I am creating a system that will ask the user to create a file that will store to a text file, Once the user created the file I have a class that will let the user input the subject name that has been created, However, I keep on getting this java.util.nosuchelementexception.Here's my code:
public void display_by_name()
{
String id, name,total;
String key[]=new String[30];
String value[]=new String[30];
int i=0;
[code]....
View Replies
View Related
Nov 10, 2014
How to write a driver program, this my code I have :
import java.util.Date;
public class myAccount {
public static void main(String[] args) {
//create an instance object of class Stock
Account myAccount = new Account(012233445566, 20000.00, 0.045);
[Code] ......
View Replies
View Related
Jul 11, 2014
I'm trying to make a calendar that, when you click on the date, the result are stored in a map and visualized in a table that refers to a container.
I successfully created the map mechanism, but I have a problem on the list....
I add the rows in this way:
Object newItemId = container.addItem();
Item riga = container.getItem(newItemId);
riga.getItemProperty("Timestamp").setValue(fara);
riga.getItemProperty("Date").setValue(asa);
.
How can I delete a row in the list, when all I have in input is the "Timestamp" information, in a Long value?
BTY, I'm using NetBeans with Vaadin extension
View Replies
View Related
Apr 12, 2014
My remove(item E) method is working fine if I remove an item that is in the list. However, it has an error when I try to remove an item which is not on the list!
Linked List Class
import java.util.NoSuchElementException;
public class LinkedList<E>
{
private Node<E> head; // head node of the list
private int size = 0; // number of elements that have been added to the list
// Returns the element at a specific list index.
// Big-O: O(n) (due to the nodeAt call, which must traverse the list)
public E get(int index)
[code]...
View Replies
View Related
Jan 16, 2015
I want my jSpinner value "0" to be removed on button click. and I want my jSpinner and jFormattedTextfield and jTextfield value "0" to be Highlighted(e.g: like highlighted by mouse double click) on button click.By removed I mean: nothing to be in the jSpinner. empty as any textfield. the jSpinner default value is 0 and on Click I want the value of the jSpinner to be removed and Highlighted, I need both examples code.
View Replies
View Related
Apr 29, 2015
1. BALL
import javax.swing.Timer;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Ball extends JPanel {
private int delay = 10;
private Timer timer = new Timer(delay, new TimerListener());
private int x = 0; private int y = 0;
[Code] ...
View Replies
View Related
Mar 13, 2014
Right now i am working on some java using BlueJ and trying to insert and remove data from an arraylist through a public class or from a new class.
I want it to have it as like a database were you can add and remove data but have a limit of storing.
View Replies
View Related
Mar 18, 2015
How can I remove the ActionListener from the buttons of my application after i have got something happen.
Please consider the following application:
Java Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Exer1218659 extends JFrame {
private String[] textButtons;
private Container contents;
[Code] .....
After the line 37 executes I expect that the ActionHandler (ah) will be removed from all of the buttons but this do not happen, then all the remaining button still responding to the clicks. Where is the problem in my code.
View Replies
View Related
May 7, 2014
My program gives me an error when I try to "digUp" the purse. The error appears in the purse class.
import java.io.*;
public class Purse
{
//Fields
public double gp;
public double gold;
public double silver;
public double copper;
public double platinum;
public static final double GOLD_VALUE = 1;
[Code] ....
In the digUpPurse() method, it tells me
java.lang.NullPointerException
null
What this means.
View Replies
View Related