Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JDBC SIMULATING AN ELEVATOR

Have Programming Question? Ask it here!
 
 
 


placid
SIMULATING AN ELEVATOR
0 Answer(s)      4 years and 3 months ago
Posted in : JDBC


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

Advertisement
View Answers

Related Tutorials/Questions & Answers:
SIMULATING AN ELEVATOR - JDBC
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
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
Advertisements
20 Futuristic Technologies that are going to Change the World
is the next leap we can expect. 20   Space elevator.... A Japanese farm announced making a 36,000 km elevator to let us reach in space without... for such a tech maneuver that would wheeze us all the way to space just on an elevator
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
I couldn't solve it
office.  A main method to test the class by simulating a minioofice with 3
Java Programming: Section 2.1
as the programs I describe. Here, just for fun, is an applet simulating the HelloWorld
Switching on Object Handles - Java Tutorial
might be interested, friends and foe. Simulating Switch Statements
Dynamic Proxies - Short Tutorial
of simulating an arbitrary interface, from the "invocation logic", that is the part
Free Java Books
is the subject area of a particular programming effort, such as "accounting," "elevator
Ajax Framework
by the server sent to the client (server-sent events) simulating user actions
Advertisements
 

 

 

DMCA.com