Question
Recently a young member of the family received a remote-controlcar as a present. He used it to terrify the cat, give the dog something to
Recently a young member of the family received a remote-controlcar as a present. He
used it to terrify the cat, give the dog something to chase, andannoy the grownups.
After he went to bed, I took a look at (i.e., played with) the carand the controller. The
controller has five options, turn left, turn right, go forward, goback, and stop.
Hummm. . . looks to me like a good object to simulate, digitally,with a little Java and
some object-oriented programming. So, you are going to build andtest a digital remote-
control car.
Your RCCar (RCCar.java) will have the following class membersexactly.
One variable that will hold the distance the car has traveled. (5points)
Five methods
One method that when called will return a string indicating thatthe car has turned
left. (12 points)
One method that when called will return a string indicating thatthe car has turned
right. (12 points)
One method that when called will return a string indicating thatthe car has
stopped. (12 points)
One method that when called will return an integer value indicatinghow far the
car has travelled forward at the rate of 3 ft/sec. This method willreceive as an argument
an integer value indicating how long the car has been travelingforward. (12 points)
One method that when called will return an integer value indicatinghow far the
car has travelled backwards at the rate of 3 ft/sec. This methodwill receive as an
argument an integer value indicating how long the car has beentraveling backward. (12
points)
Simple, really.
Now let’s write a Java application that will put this little car tothe test. Your Java
application (RCCarTest.java) will do the following.
Instantiate an object of the RCCar class. (10 points)
In a sentinel controlled looping structure the person playing withthe car will have
the following six options (25 points)
Turn left
Turn right
Stop
Go forward for a number of seconds to be determined by theplayer
Go backwards for a number of seconds to be determined by theplayer
End the game
Each time the player selects an option the RC Car object willrespond appropriately to
the player, i.e., if the player selects the turn left option the RCCar will respond with a
“Turning Left” response or something similar that the applicationwill then display to the computer screen. For the go forward and gobackward options the response to the
screen will be something on the order of “Going forward for nnumber of feet” where n is
the number of feet the car traveled in the time allowed. A modestamount of very simple
math will be involved here.
We are nearly at the end of the semester. There are no new conceptsrequired to solve
this problem so I will severely penalize any solutions that havethe following flaws –
? Unnecessary code – If I find any code in your programs that I candelete and your
code still works, it’s unnecessary. (-10 to 50 points)
? Solutions that do not contain, exactly, the class membersindicated above. Missing or
extra methods, missing or extra variables are serious errors. (-50points)
? The loop in the application will, obviously, contain a selectionstructure. I expect the
loop and the selection structure to be clear and simple. Complexityis not your friend
here. (-25 points)
I will always prefer solutions that are clear, simple, void ofunnecessary code, and with
well thought out user interfaces.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started