70 likes | 430 Views
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()
E N D
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
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: 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: 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: 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: 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: 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