I am attempting to complete an assignment but an having some major issues as my java knowledge is basic to say the least. Below is what I am trying to do and below that is the current code that I have. Am I way off base or on the right track?
Wings Coffee Shop
A local coffee shop sells a variety of different items shown below to their customers. You are asked to write a Java application that can be used to keep track of these items. Additionally, this program provides a way to print out a listing of the items.
Item Name Price Coffee $1.00 Water $2.00 Milk $1.50 Bagel $1.25 Donut $0.75
Your program will create a class, named Item. This class has the following: * A String instance variable to hold the item name * A double instance variable to hold the price * A constructor that takes a String and double to initialize the instance variables * A get and set method for each instance variable
Once you have this class created, you write a second class named CoffeeDriver. This class has the following methods: * sortName – this method sorts the array of items by item name and then displays the name and price of all items on the screen * sortPrice – this method sorts the array of items by item price and then displays the name and price of all items on the screen * main - It creates an array of Item objects using the data above to set each Item's information. After initializing the array, prompt the user for how they want to see the list – sorted by name or price. Then call the appropriate method.
public class Item
{
private double coffee;
private double water;
private double milk;
private double bagel;
private double donut;
public Item(double coffee, double water, double milk, double bagel, double donut)
{
coffee = 1.00;
water = 2.00;
milk = 1.50;
bagel = 1.25;
donut = 0.75;
}
{
System.out.println("Item Name Price");
System.out.println("Coffee $1.00");
System.out.println("Water $2.00");
System.out.println("Milk $1.50");
System.out.println("Bagel $1.25");
System.out.println("Donut $0.75");
}
}
I don't quite understand the whole project but this is as much as I gathered so far. It asks for me to use a string and a double but I am unsure how to combine the two.