Technology Get the latest on technology, electronics and software…

Need help with java program

Thread Tools
 
Old 10-24-2011, 05:27 PM
  #1  
2016 Acura TLX
Thread Starter
 
honda_nut's Avatar
 
Join Date: Aug 2007
Location: Norcal
Age: 34
Posts: 851
Received 137 Likes on 89 Posts
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
Old 10-24-2011, 05:29 PM
  #2  
2016 Acura TLX
Thread Starter
 
honda_nut's Avatar
 
Join Date: Aug 2007
Location: Norcal
Age: 34
Posts: 851
Received 137 Likes on 89 Posts
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

}
}
Old 10-24-2011, 05:29 PM
  #3  
2016 Acura TLX
Thread Starter
 
honda_nut's Avatar
 
Join Date: Aug 2007
Location: Norcal
Age: 34
Posts: 851
Received 137 Likes on 89 Posts
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)
{

}

}
Old 10-24-2011, 05:29 PM
  #4  
2016 Acura TLX
Thread Starter
 
honda_nut's Avatar
 
Join Date: Aug 2007
Location: Norcal
Age: 34
Posts: 851
Received 137 Likes on 89 Posts
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;
}

}
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Yumcha
Automotive News
70
12-07-2020 05:39 PM
heykosal
1G RDX DIY & FAQ
3
11-16-2020 03:59 PM
joflewbyu2
5G TLX (2015-2020)
139
10-08-2015 11:16 AM
Yumcha
Automotive News
2
09-17-2015 08:57 PM
Yumcha
Automotive News
4
09-13-2015 01:59 PM



Quick Reply: Need help with java program



All times are GMT -5. The time now is 01:14 PM.