Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java You operate several hot dog stands distributed throughout town. Define a

ID: 3810459 • Letter: I

Question

In Java

You operate several hot dog stands distributed throughout town. Define a class named HotDogStand that has an instance variable for the hot dog stand's ID number and an instance 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 by one the number of hot dogs the stand has sold. The idea is that this method will be invoked each time the stand sells a hot dog so that you can track the total number of hot dogs sold by the stand. And another method that returns the number of hot dogs sold. Finally, 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.

Write a main method to test your class with at least three hot dog stands that each sell a variety of hot dogs.

The defined class will contain:

* At least two constructor methods

* Getters and Setters

* A "copy" constructor

* A "toString" method

* An "equals" method

* A "finalize" method

* A "dispose" method

Explanation / Answer

HI, Please find my implementation.

You have not explained about 'dispose' method, so i have not implementd.

public class HotDogStand {

   private int standId;

   private int soldDogNum;

  

   // static variable to keep track of total sold dogs from all hot stand

   private static int totalSoldDog = 0;

  

   //first constructor

   public HotDogStand(int id) {

       standId = id;

       soldDogNum = 0;

   }

   // second constructor

   public HotDogStand(int standId, int soldDogNum) {

       super();

       this.standId = standId;

       this.soldDogNum = soldDogNum;

   }

   // copy constructor

   public HotDogStand(HotDogStand hotDogStand){

      

       standId = hotDogStand.getStandId();

       soldDogNum = hotDogStand.getSoldDogNum();

   }

   // getters and setters

   public int getStandId() {

       return standId;

   }

   public int getSoldDogNum() {

       return soldDogNum;

   }

   public void setStandId(int standId) {

       this.standId = standId;

   }

   public void setSoldDogNum(int soldDogNum) {

       this.soldDogNum = soldDogNum;

   }

  

   //incremet sold dog number

   public void justSold(){

       totalSoldDog++;

       soldDogNum++;

   }

  

   @Override

   public String toString() {

       return "Stand Id: "+standId+", Nubber of sold dogs: "+soldDogNum;

   }

  

   @Override

   public boolean equals(Object obj) {

       HotDogStand temp = (HotDogStand)obj;

       if(this.standId == temp.getStandId())

           return true;

       return false;

   }

  

   @Override

   protected void finalize() throws Throwable {

       super.finalize();

   }

  

   public static int getTotalSoldDogNum(){

       return totalSoldDog;

   }

   // main method

  

   public static void main(String[] args) {

      

       HotDogStand h1 = new HotDogStand(1);

      

       HotDogStand h2 = new HotDogStand(2);

      

       h1.justSold();

       System.out.println(h1.toString());

       System.out.println(h2.toString());

      

       h2.justSold();

       System.out.println(h2.toString());

       System.out.println("Total Sold dogs: "+HotDogStand.getTotalSoldDogNum());

      

       h1.justSold();

       h1.justSold();

       h2.justSold();

      

       System.out.println("Total Sold dogs: "+HotDogStand.getTotalSoldDogNum());

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote