1 / 7

1: create the object

1: create the object Car String regNo int mileage int fuel String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Car() constructor Constructor method: Car()

Gabriel
Download Presentation

1: create the object

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1: create the object Car String regNo int mileage int fuel String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Car() constructor Constructor method:Car() Instruction:Car myCar = new Car() show it exit

  2. myCar : Car String regNo = ? int mileage = ? int fuel = ? String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) 2: set registration number Message:setRegNo( “RWK 432X” ) Sent to object:myCar show it exit

  3. 3: set mileage myCar : Car String regNo = “RWK 432X” int mileage = ? int fuel = ? String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Message:setMileage( 34219 ) Sent to object:myCar show it exit

  4. 4: get mileage myCar : Car String regNo = “RWK 432X” int mileage = 34219 int fuel = ? String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Message:getMileage( ) Sent to object:myCar show it exit

  5. 5: set fuel myCar : Car String regNo = “RWK 432X” int mileage = 34219 int fuel = ? String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Message:setFuel( 20 ) Sent to object:myCar show it exit

  6. 6: make a journey myCar : Car String regNo = “RWK 432X” int mileage = 34219 int fuel = 20 String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) Message:makeJourney( 50,8 ) Sent to object:myCar show it exit

  7. 7: The end:- the final state of the object myCar : Car String regNo = “RWK 432X” int mileage = 32469 int fuel = 12 String getRegNo() void setRegNo(num) int getMileage() void setMileage(miles) int getFuel() void setFuel(litres) void makeJourney(miles,litres) void refuel(litres) show it exit

More Related