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

1 Expert Approved Answer
Step: 1 Unlock

Python class car def initself model rego year color selfmodel model selfrego rego selfyear year self... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!