Need help with java program
#1
2016 Acura TLX
Thread Starter
Need help with java program
hi guys, i was wondering if anyone can help me with my java assignment.
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
Uploaded with ImageShack.us
#2
2016 Acura TLX
Thread Starter
the stuff in yellow, i have figured out.
but i'm not too sure how to do the "store class"
here is my code:
public class StoreDriver
{
public static void main(String[] args)
{
Store mystore = new Store("Neil's Mini-Market");
mystore.doReport(); // Show regular prices
mystore.doReport(true); // Show sale prices
mystore.doReport(1111); // Show employee prices
}
}
but i'm not too sure how to do the "store class"
here is my code:
public class StoreDriver
{
public static void main(String[] args)
{
Store mystore = new Store("Neil's Mini-Market");
mystore.doReport(); // Show regular prices
mystore.doReport(true); // Show sale prices
mystore.doReport(1111); // Show employee prices
}
}
#3
2016 Acura TLX
Thread Starter
public class Store
{
// Attributes (instance variables) go here
private String storeName;
Item itemRef;
// Constructor
public store()
{
Item 1 = new Item (“Milk (Gallon)”, 2.45, 3.59);
Item 2 = new Item (“Wheat Bread (Loaf)”, 1.24, 2.99);
Item 3 = new Item (“Butter (pound)”, 3.25, 4.99);
Item 4 = new Item (“Peanut Butter (jar)”, 1.88, 2.99);
Item 5 = new Item (“Berry Jelly (jar)”, 1.55, 2.29);
}
public doReport()
{
}
public doReport(boolean saleFlag)
{
}
public doReport(int empNum)
{
}
}
{
// Attributes (instance variables) go here
private String storeName;
Item itemRef;
// Constructor
public store()
{
Item 1 = new Item (“Milk (Gallon)”, 2.45, 3.59);
Item 2 = new Item (“Wheat Bread (Loaf)”, 1.24, 2.99);
Item 3 = new Item (“Butter (pound)”, 3.25, 4.99);
Item 4 = new Item (“Peanut Butter (jar)”, 1.88, 2.99);
Item 5 = new Item (“Berry Jelly (jar)”, 1.55, 2.29);
}
public doReport()
{
}
public doReport(boolean saleFlag)
{
}
public doReport(int empNum)
{
}
}
#4
2016 Acura TLX
Thread Starter
public class Item
{
// Attributes (instance variables) go here
private static int nextItemNum = 1;
private int itemNum;
private String description;
private double cost;
private double price;
// Constructor
public Item(String origDesc, double origCost, double origPrice)
{
set(origDesc, origCost, origPrice);
itemNum = nextItemNum;
nextItemNum++;
}
// default constructor
public Item ()
{
itemNum = 0;
description = "Unknown";
cost = 0;
price = 0;
}
public String toString ()
{
String temp;
temp = itemNum + " " + description + ('\t') + price;
return temp;
}
private void set(String newDesc, double newCost, double newPrice)
{
description = newDesc;
cost = newCost;
price = newPrice;
}
private void set(String newDesc, double newCost)
{
description = newDesc;
cost = newCost;
price = cost * 1.5;
}
public String getDesc( )
{
return description;
}
public double getPrice( )
{
return price;
}
public double getPrice(boolean)
{
return price * 0.8;
}
public double getPrice(int)
{
return cost * 1.1;
}
public double getCost( )
{
return cost;
}
}
{
// Attributes (instance variables) go here
private static int nextItemNum = 1;
private int itemNum;
private String description;
private double cost;
private double price;
// Constructor
public Item(String origDesc, double origCost, double origPrice)
{
set(origDesc, origCost, origPrice);
itemNum = nextItemNum;
nextItemNum++;
}
// default constructor
public Item ()
{
itemNum = 0;
description = "Unknown";
cost = 0;
price = 0;
}
public String toString ()
{
String temp;
temp = itemNum + " " + description + ('\t') + price;
return temp;
}
private void set(String newDesc, double newCost, double newPrice)
{
description = newDesc;
cost = newCost;
price = newPrice;
}
private void set(String newDesc, double newCost)
{
description = newDesc;
cost = newCost;
price = cost * 1.5;
}
public String getDesc( )
{
return description;
}
public double getPrice( )
{
return price;
}
public double getPrice(boolean)
{
return price * 0.8;
}
public double getPrice(int)
{
return cost * 1.1;
}
public double getCost( )
{
return cost;
}
}
Thread
Thread Starter
Forum
Replies
Last Post
joflewbyu2
5G TLX (2015-2020)
139
10-08-2015 11:16 AM