Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 7

464 bytes added, 10:16, 3 December 2017
INVESTIGATION 1: Classes and objects
As you try to design the classes you will quickly realise that there is a potentially infinite number of properties (components) and methods that any class can have. What you choose to include in your class definition should be guided by what you intend to do with it. For example if the tire tread depth in the cars is important in your application - you should include it in your Car class. But if you don't care about when the last oil change was or you don't have the means of obtaining that information - there's no point in adding that to the description of the Car class.
 
In your main code - create some objects (perhaps the ones from the table plus whatever properties you came up with) and call the methods on those objects.
 
You may find that when you have more than one or two objects of a type - it will be easier to store them in a Python list instead of having separate variables for each of them. Again - which makes more sense depends entirely on what you do with your objects in your application in any particular situation.
= LAB 7 SIGN-OFF (SHOW INSTRUCTOR) =