CarDemo - porsche.accelerate(); porsche.accelerate();...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** Car class demo program Chapter 6, Programming Challenge 2 */ public class CarDemo { public static void main(String[] args) { //step 11: create a Car object, it's yearmodel is 2004 and the mamke of the car is Porsche Car porsche = new Car(2004, "Porsche"); //step 12: Display the current status by calling the three accessor methods System.out.println(porsche .getSpeed()); System.out.println(porsche .getYearModel()); System.out.println(porsche .getMake()); //step 13: Accelerate the car five times by calling accelerate meothd .
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: porsche.accelerate(); porsche.accelerate(); porsche.accelerate(); porsche.accelerate(); porsche.accelerate(); //step14: Display the speed by calling getSpeed method. System.out.println(porsche .getSpeed()); //step15: Brake the car three times by calling brake method. porsche.brake(); porsche.brake(); porsche.brake(); //step 16: Display the speed. System.out.println(porsche .getSpeed()); } }...
View Full Document

Ask a homework question - tutors are online