Question: Write a class car with attributes model, rego, year and color. Also create methods in the class to set and get each attribute such as
Write a class "car" with attributes "model", "rego", "year" and "color". Also create methods in the class to set and get each attribute such as setModel(modelName) and getModel() to set and obtain the model of the car's object. Similarly write set and get methods for all the attributes of the class.
Test:
c1 =car()
c1.setModel("Honda Accord")
print(c1.getModel())
Result:
Honda Accord
Step by Step Solution
There are 3 Steps involved in it
Python class car def initself model rego year color selfmodel model selfrego rego selfyear year self... View full answer
Get step-by-step solutions from verified subject matter experts
