Results 1 to 3 of 3
- 02-01-2012, 09:25 PM #1Member
- Join Date
- Feb 2012
- Rep Power
All I need is a solution and only than guidance
1.Add a new class to the project called CAR. add a member variable of type int called velocity.
2.Add a method to the CAR class called accelerate (). The return value should be void and it should have no parameters. This method should increase the velocity by 10.
3.Add a similar method called brake() that decreases the velocity be 20.
4.Add a similar method stop() that sets the velocity to 0.
5.Add a method called setVelocity() that has an int as a parameter and returns void. The value that is passed in to this method should become the new velocity of the car.
6.Add a method called getVelocity() that has no parameters and returns the velocity.
7.Compile the CAR class.
8.Create new class called CarProgram.
9.Within the main() method of CarProgram , declare a CAR reference called porsche. Assigne porsche to a new CAR.
10.Set the velocity to be 55 using the set velocity() method.
11.Use getVelocity() and the System.out.println() method to display the velocity to make sure it works.
12.Invoke accelerate(), brake(), and stop() several times and display the velocity each time to ensure that the methods are working properly.
13.Compile and run the CarProgram.
I know it is lame, and i am lame, but all I want is to see how it's done. I can't even complete step 2. I am struggaling with english and sometimes it is very hard to interpret the what i am asked to do. Please help me with this.
- 02-01-2012, 09:45 PM #2
Re: All I need is a solution and only than guidance
This is a forum. Not a homework service. Recommended reading: How to ask questions the smart way
I'm closing this thread. If you have a specific question about your own efforts, feel free to start another thread.
Note that repeated homework dumps may result in a ban.
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 02-01-2012, 09:47 PM #3
- By meenakshipuni in forum New To JavaReplies: 3Last Post: 10-30-2011, 01:51 PM
- By bengregg in forum Java AppletsReplies: 15Last Post: 01-11-2011, 11:04 AM
- By sairam in forum New To JavaReplies: 1Last Post: 06-30-2010, 10:21 AM
- By Curtiz in forum AWT / SwingReplies: 1Last Post: 03-23-2010, 06:41 PM
- By gizdev in forum New To JavaReplies: 5Last Post: 09-07-2008, 08:14 PM