r/pythonhelp • u/Noobie_python_user • Feb 02 '21
HOMEWORK Need guidance in using python classes.
Hello,
before I begin I just wanted to say that I am brand new to any type of programming So thank you in advance for your patience and help.
I am currently working on a school assignment utilizing python classes to:
1.) Create a Vehicle class with the following attributes and functions:
Attributes: make, model, color, fuelType, options (which will be defined as a python list chosen by the user when presented with a menu of programmer chosen vehicle options that can apply to both cars and pickup trucks
Options: power mirrors, power locks, power windows, remote start, backup camera, bluetooth, cruise control, GPS
functions: getMake(), getModel(), getColor(), getFuelType(), getOptions().
2.) Create a Car class as a child of the Vehicle class with the following attributes and functions:
Attributes: engineSize, numDoors
Functions: getEngineSize(), getNumdoors()
3.) Create a Pickup class as a child of the Vehicle class with the attributes and functions :
Attributes: cabStyle, bedLength
Functions: getCabstyle(), getBedLength()
4.) Your program will prompt the user to create at least one object of each type (Carand Pickup) allowing the user to define the attributes of the vehicles in their garage.
5.) Using a menu system and capturing user input your program will allow the user the choice of adding a car or pickup truck and define the vehicle's attributes.
6.)
The user will choose from a list of options to add to the vehicle's options list and must choose a minimum of one vehicle option per vehicle.
7.) Your program must allow the user to have multiple vehicles in their virtual garage and must have at least one Car and one Pickup.
8.) When the user is finished adding vehicles to their virtual garage the program will output the vehicles in their garage and their attributes.
whew, what a list! Alas, I am lost in the woods on this one as I'm not quite sure where to begin with the user inputs, and I don't really know what the requirements are asking for within the functions. All I have done so far is code the classes (See screenshot) should I begin with creating a class method for the inputs?
Again I appreciate any advice on how I should move forward with the rest of the requirements.

1
u/DaaxD Feb 02 '21 edited Feb 02 '21
For sake of clarity and your own mental health, please add empty lines between the functions. This will make your code more pleasant to read when easier distinguish where the function starts and where it ends. Make sure the indentation is right.
Is this a command line application or does it have graphical user interface (GUI)?
In either case, you might want to start by implementing things step by step in small increments. You do know how to eat an elephant, right? One bite at the time.
So you might want to start by implementing your first interaction, which creates a car with some default options. Make sure it works before moving forward.
Then, add the interaction which allows user to choose his options for the car. Again, make sure that your new feature works and that you haven't broken anything while adding the new feature.
Then, continue by adding the ability to add multiple cars. Make sure everything works before moving forward.
... and so on and so on, until you have implemented all the requirements.
You also might want to use pen and paper to draw out your thoughts. At least I find it easier to think with pen and paper. :)
Edit: It seems that you have also forget to add base class initializations in your derived classes Car and Pickup. I assume this is just a small slip up.