File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes coding Excercise Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "coding Excercise" Watch "coding Excercise" New topic
Author

coding Excercise

Jayasri Alaparthi
Ranch Hand

Joined: Aug 14, 2006
Posts: 67
Hi Friends,
Please guide me in doing this excercise

Exercise #1: Develop an inheritance hierarchy, utilizing interfaces, abstract classes, and concrete classes, for two cars and a motorcycle. Decide where the following instance variables should be defined in the hierarchy. Use a default constructor for each Class to assign values to these instance variables. Hint: You should pay special attention to the modifiers (public, private, protected) of the variables.
make � String
color � String
numberOfWheels � int
gearsOnLeft � boolean
numberOfDoors � int
currentSpeed � int
engineState � String
gearPosition - String

Exercise #2: Add methods to change the state of your vehicle. Decide where the following methods should be in your hierarchy. Create logic to not allow the driver to exceed the vehicle�s maximum speed. Hint: The �getMaximumSpeed� method should be a protected abstract method.
startEngine()
increaseSpeed(int amount)
stopEngine()
getMaximumSpeed()
shift(String gearPosition)

Exercise #3: Create a class called �Driver� that contains the three vehicles described above. Use a List to represent the vehicles. Create a �drive� method to iterate over the list of vehicles and drive them in succession. The �drive� method should start the vehicle, shift the gear from park to drive, increase the speed from 0 to 60, and slow down to 0, shift from drive to park, and stop the engine. Create a �main� method to be used to initiate the operation.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Bhargavi kurra:
... Please guide me in doing this excercise...

We are happy to guide you, but we will not do it for you.

What have you done so far? Where are you stuck? What are your specific questions?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch

particularly:
http://faq.javaranch.com/java/DoYourOwnHomework

and:
http://faq.javaranch.com/java/ShowSomeEffort


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: coding Excercise