Professional Documents
Culture Documents
Student Id 7877146
Task 01 –
Implement the following class digram
Car
Attributes
-colour:String Variable of type String to store the Car
colour
-price:double Variable of type double to store the Car
price
Year:int Variable of type int to store the Car make
year
Constructor
+Car(String, double, int) Parameter constructor
Methods
+getColour():String Returns colour of object
+setColour(String):void Sets colour of object
+getPrice():double Returns price of object
+setPrice(double):void Sets price of object
+toString():String returns the attributes of object as a String
Create a Main class which has a main(String[] args) and do the following in the main method
1. Create three objects: car1:(Values: “Red”, 95.5, 2020)
car2:(Values: “Blue”, 120.9, 2018)
car3:(Values: “Black”, 155.0, 2022)
2. Use the set method to change the colour of (car1) to “Yellow”.
3. Use the set method to change the price of (car1) to 99.3.
4. Create a list of type ArrayList<Car>, and store car1, car2 and car3 into the dynamic list
5. Display the list.