JAVA PROGRAMNEED TO BE SUBMITTED TOMORROW you operate 3 hot dog stands distributed throughout town. Define a class names HotDogStand that has an instance variable for the hot dos 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 hotdogs that stand has sold so that you can track the total umber of hot dogs sold by the stand. Add another method that returns the value in this variable.Write a main method to test your class with at least three ot dog stands that each sell a variety of hot dogs.defined class HotDogStand.java and will also contain : A default constructor An overloaded constructor Getters and Setters A ‘copy’ constructor, A ‘toString’ method, An ‘equals’ method, A ‘finalize’ method,

Question
Asked Apr 2, 2019
198 views

JAVA PROGRAM

NEED TO BE SUBMITTED TOMORROW

 

you operate 3 hot dog stands distributed throughout town. Define a class names HotDogStand that has an instance variable for the hot dos 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 hotdogs that stand has sold so that you can track the total umber of hot dogs sold by the stand. Add another method that returns the value in this variable.

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

defined class HotDogStand.java and will also contain :

 A default constructor
 An overloaded constructor
 Getters and Setters
 A ‘copy’ constructor,
 A ‘toString’ method,
 An ‘equals’ method,
 A ‘finalize’ method,

check_circle

Expert Answer

Step 1

The following override methods are created along with @Override annotation:

  • equals
  • finalize
  • toString

The following constructors are created:

  • default empty constructors with default values for instance variables
  • non-empty constructor
  • copy constructor

Getter and setter methods are created for the instance variables. In the main method 4 instances of the class are created and the above constructors, overridden methods and getter/setter methods are tested.

Step 2

The java program is given below:

class HotDogStand{

                private int standID, noSold;

                //default constructor

                HotDogStand(){

                                this.standID = 1000;

                                this.noSold=0;

                }

                //overloaded constructor

                HotDogStand(int standID, int noSold){

                                this.standID = standID;

                                this.noSold = noSold;

                }

                //copy constructor

                HotDogStand(HotDogStand hds){

                                this.standID = hds.getStandID();

                                this.noSold = hds.getNoSold();

                }

                void justSold(){

                                noSold++;

                }

                //getter method

                int getNoSold(){

                                return noSold;

                }

                //setter method

                void setStandID(int standID){

                                this.standID = standID;

                }

                //getter method

                int getStandID(){

                                return standID;

                }

                //toString method

                @Override

                public String toString(){

                                return "The stand has ID " + this.standID + " and has sold " + this.noSold + " hot dogs";

                }

&n...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you

Show more Q&A add
question_answer

Q: Use Java to answer the question. 5-1) (Count positive and negative numbers and compute the average o...

A: Java codeimport java.util.Scanner; public class AvgWithLoop {      public static void main(String[] ...

question_answer

Q: This is for pygame Ball Class: The Ball class inherits from Drawable and it will draw a circle at it...

A: The class Ball to draw a circle at its current location:Import the Drawable class and pygame module....

question_answer

Q: Construct Turing machines that will accept the following languages on {a, b}: L = L (aaba*b).

A: Turing machine: Turing machine is a model of a hypothetical computing machine which can use a predef...

question_answer

Q: Task_1: Base-10 conversion of the following Base-2 values? 101101   2. 011101   3. 1001   4. 11111...

A: Conversion of Base-2 to Base-10: 1. 101101:

question_answer

Q: How become a ggod programmer?

A: Good programmer:Becoming programmer is not a big thing; it is all about learning the logics of the p...

question_answer

Q: Write a class, AgeMessages , which does the following:a. Ask the user to enter age using a Scannerb....

A: The given below is the code to enter the age through user and print the message according to age. To...

question_answer

Q: Find context-free grammars for the following languages (with n ≥ 0, m ≥ 0)  L = {anbm : n = m − 1}.

A: Solution:A context-free grammar (CFG) is a hard and fast of recursive rewriting guidelines which is ...

question_answer

Q: Create a Crow's Foot ERD to include the following business rules for the ProdCo company:a. Each sa...

A: We will draw the diagram one part by part. So first we willd ra diagram for very first two points.a)...

question_answer

Q: Try giving these 2 commands $ echo cat$ cat echoExplain the differences between the output of each c...

A: echo command:echo command is used to display the line of text passed as an argument. It is a built i...