Ok so I have a problem.
You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has a member variable for the hot dog stand's ID number and a member variable for how many hot dogs the stand has sold that day. Create a constructor that allows a user of the class to initialize both values.
Also create a method named justSold that increments the number of hot dogs the stand has sold by one. The idea is that this method will be invoked each time the stand sells a hot dog so that we can track the total number of hot dogs sold by the stand. Add another method that returns the number of hot dogs sold.
Finally, add a static variable that tracks the total number of hotdogs sold by all hot dog stands and a static method that returns the value in this variable.
Write a main method to test your class with at least three hot dog stands that each sell a variety of hot dogs.
private static int totalSold = 0; public static int getTotalSold() { return totalSold; } private String name; private int id; private int numSold; public HotDogStand(String name, int id) { this.name = name; this.id = id; } public void setJustSold() { numSold++; totalSold++; } public int getNumSoldToday() { return numSold; } public int getID() { return id; } public String getName() { return name; } public String toString() { return name+" ("+id+") - "+numSold; } public HotDogStand(HotDogStand rhs) { id = rhs.id; name = ""+rhs.name; numSold = rhs.numSold; } } class Test { public static void main(String[] args) { HotDogStand one = new HotDogStand("one", 1); HotDogStand two = new HotDogStand("two", 2); HotDogStand three = new HotDogStand("three", 3); System.out.println(one); System.out.println(two); System.out.println(three); System.out.println("Total: "+HotDogStand.getTotalSold()); one.setJustSold(); two.setJustSold(); three.setJustSold(); System.out.println("Name\tID\tNumber Sold"); System.out.println("________________________________"); System.out.println(one.getName()+"\t"+one.getID()+"\t"+one.getNumSoldToday()); System.out.println(two.getName()+"\t"+two.getID()+"\t"+two.getNumSoldToday()); System.out.println(three.getName()+"\t"+three.getID()+"\t"+three.getNumSoldToday()+"\t"); System.out.println("Total: "+HotDogStand.getTotalSold()); HotDogStand four = new HotDogStand(one); } }
How come when I run it nothing shows up?