Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HotDogStand
- {
- // Add a static variable that tracks the total number of hot dogs sold by all hot dog stands and a static method that returns the value in this variable.
- private static int totalSold = 0;
- public static int getTotalSold()
- {
- return totalSold;
- }
- // *Name of each hot dog stand
- private String name;
- // *Stand's ID number
- private int id;
- // *How many hot dogs the stand has sold that day.
- private int numSold;
- // Create a constructor that allows a user of the class to initialize values.
- public HotDogStand(String name, int id)
- {
- this.name = name;
- this.id = id;
- }
- //Also create a method named SetJustSold()(Hint ++) that increments the number of hot dogs the stand has sold by one and should also increase the TotalSold by one.
- public void justSold()
- {
- numSold++;
- totalSold++;
- }
- // Add another method that returns the number of hot dogs sold.
- public int getNumSoldToday()
- {
- return numSold;
- }
- public int getID()
- {
- return id;
- }
- public String getName()
- {
- return name;
- }
- // Create a toString() method and a copy constructor.
- public String toString()
- {
- return name+" ("+id+") - "+numSold;
- }
- public HotDogStand(HotDogStand rhs)
- {
- id = rhs.id;
- name = ""+rhs.name;
- numSold = rhs.numSold;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement