r/pythonhelp • • 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.

2 Upvotes

7 comments sorted by

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.

1

u/Noobie_python_user Feb 02 '21

Thank you for the advice, I will attempt to work through it incrementally. I also changed the format to include the spaces.

Also, this is a command line application,

1

u/Onyxus_music Feb 06 '21

Hello,

Sorry to jump in your post, but this is EXACTLY what I'm trying to do (I'm also completely new to coding), but I'm having some issues trying to figure out how to get the user's input to add a vehicle to his garage. I would love to work with you in trying to figure this out, if you don't mind. If you would like to, message me, please? This assignment is due by Sunday and I've been spending my week trying to figure it out. :(

1

u/Few_North5726 Feb 13 '21

You wouldn't happen to be in Fadi's class, would you?

1

u/[deleted] Feb 14 '21

I am! This assignment has come up out of nowhere it seems like. I am working on it myself and I am having lots of issues. I feel like we learned all about user inputs, classes, etc. throughout the book, but did not get any instruction on how to pass user input into classes. Throughout the textbook we called all the functions in the initial code, not from user input. Also, I do not recall learning about menu options unless I missed something the last few weeks. How are you coming along in this assignment?

1

u/[deleted] Apr 18 '21

Did you ever figure it out this my project for this week and I am also stuck on how to use user input?

1

u/4_eyed_craven May 11 '21

Did you ever figure this out? I'm working on the same exact exercise, and it's giving me a helluva time...