SIMULATING AN ELEVATOR
Classes, Methods, Constructors
please i need help to create an elevator program
Simulating an Elevator
write an Elevator class containing various methods.
Then, write a program that creates Elevator objects and invokes the various methods.
put comments on methods and how methods manipulate the data of an object.
1. Using (JCreator), write a class named Elevator. Add fields for
the following attributes: an int for the current floor, an int for the floor that the elevator is heading to, a boolean to denote whether the elevator is going up or down once it reaches its destination, and a boolean to denote whether the elevator doors are open or closed.
2. Add a method named goToFloor() that changes the floor that the elevator is heading to. Use the System.out.println() method to display a message that you are changing the value.
3. Add methods named openDoors() and closeDoors() that change the appropriate boolean field accordingly. Again, display a message within each method so that you can see when the methods are invoked.
4. Add methods named goingUp() and goingDown() that change the appropriate boolean field accordingly.
5. Save and compile the Elevator class.
6. Write a class named ElevatorProgram that contains main().
7. Within main(), instantiate two Elevator objects. Invoke the various methods of the Elevator
class on these two objects, ensuring that all your Elevator methods work successfully.
then add two constructors to your Elevator class.
1. Begin by opening your Elevator class from above in your text editor(JCreator).
2. Add a constructor that has a single parameter of type int to represent the current floor of the elevator. Within the constructor, assign the parameter to the appropriate field in your class. Also, display a message using System.out.println() that shows which constructor you are currently in.
3. Add a no-argument constructor that uses the this keyword to invoke your constructor in the previous step, passing in a 1 for the initial floor. Display a message that states you are currently in the no-argument constructor.
4. Modify the ElevatorProgram in above. Instantiate one of the Elevator objects using the no- argument constructor, and instantiate the other Elevator object using the one-argument constructor.
5. Run the ElevatorProgram and ensure that the constructors are working successfully
that is how the program should be.thanks for any help rendered
View Answers
Related Tutorials/Questions & Answers:
SIMULATING AN ELEVATOR - JDBCSIMULATING AN ELEVATOR Classes, Methods, Constructors
please i need help to create an
elevator program
Simulating an
Elevator
write an
Elevator class containing various methods.
Then, write a program that creates
Elevator ModuleNotFoundError: No module named 'Elevator'ModuleNotFoundError: No module named '
Elevator' Hi,
My Python... '
Elevator'
How to remove the ModuleNotFoundError: No module named '
Elevator... to install padas library.
You can install
Elevator python with following
Advertisements
need help creating a lift program - Java Beginners
please i need help to create an
elevator program
Simulating an
Elevator
write an
Elevator class containing various methods.
Then, write a program that creates
Elevator objects and invokes the various methods.
put comments on methods
assig method to test the class by
simulating a minioofice with 3 employees and 7
assig method to test the class by
simulating a minioofice with 3 employees and 7
car licensing office by
simulating a minioofice with 3 employees and 7 customers. The three employees
car licensing office by
simulating a minioofice with 3 employees and 7 customers. The three employees
car licensing office by
simulating a minioofice with 3 employees and 7 customers. The three employees
Free Java Books is the subject area of a particular programming effort, such as "accounting," "
elevator