Wednesday, October 16, 2013

Beginning Java Programming Help

Hello, All. I'm a beginner with Java writing and would greatly appreciate a hand with the problem below:



A student has decided to fly his remote controlled airplane. The airplane has about 12 minutes of flight without any extra weight. For every 1/2 of a pound added, the lifetime of the airplane is reduced by one minute. Additionally, the following moves drain the battery life accordingly:




Maneuver Battery Life Reduction (minutes)



Take-off 0.2

Loop 0.3

Land 0.2

Fly 100 feet 0.3



If the battery life reaches zero (or less than zero), the means the plane will crash. This means the student must land the airplane to recharge. Upon recharging, the battery is reset to the maximum lifetime (minus the weight).



You are to write two classes. The first class, is called RCPLANE. In this class you must have the following:



* A constructor which requires the user to input the weight of the load used. If the weight of the load is greater than 2 pounds, the plane will not take off. In this case, a message should indicate the weight is too heavy, and the program exits.

* A method called TakeOff, which "instructs" the plane to take off. If the plane is already in the air, then a message should indicate the plane is already in the air, and no changes to battery life is needed.

* A method called Land, which "instructs" the plane to land. If the plane is already on the ground, then a message should indicate the plane is already on the ground, and no changes to battery life is needed.

* A method called Loop, which "instructs" the plane to loop in the air. The plane can only do this if it is on the ground. In this case, a message should indicate the plane is on the ground, and no changes to battery life is needed.

* A method called Fly, which "instructs" the plane to fly. The user must input the distance to fly. The plane can only do this if it is in the air. If the plane is already in the air, then a message should indicate the plane is already in the air, and no changes to battery life is needed.

* A method called GetDistance, which returns the total distance travelled

* A method called GetBatteryLife, which returns the total battery life

* A method called Recharge, which recharges the battery and resets the distance travelled to zero



The second class, which is a main class, is called RCPLANETESTER. In this class, you must construct the airplane, and give it the following sequential directions:



* Take off

* Fly 200 feet

* Loop

* Take off

* Fly 300 feet

* Loop

* (Display Battery Life)

* Fly 300 feet

* Loop

* Fly 250 Feet

* Loop

* (Display Battery Life)

* (Display Total Distance)

* Recharge

* Land

* Fly 200 feet

* Loop

* Recharge

* Takeoff

* Fly 1000 feet

* (Display Battery Life)

* (Display Total Distance)

* Fly 10000 feet



(Note that you may decide to write the methods in any order as you can handle them in the questions, but the orders suggested above are the best if you decide to follow those. Note however that all methods must be written in order to get the full points. Recall that partial credits are also obtainable for your best efforts)
Full Post

No comments:

Post a Comment