[Python] Creating a Bus System in Python

Discussão em 'Python' iniciado por Stack, Junho 22, 2025.

  1. Stack

    Stack Membro Participativo

    I'm in a crash-course class that teaches us Python in 6-weeks and I've been having a hard time keeping up. Our teacher has now told us to work on a program that basically imitates a "Bus System" that revolves around three destinations and what we have to do is create different modules and classes and make them all interact with each other to work.

    My problem is that I just don't understand how he wants me to do this and also I don't know what type of classes I need to have. This is how he describes the problem:

    Build a model of a bus company. There should be at least 3 destinations (don't have too many!), several buses (each will be built by a Bus class, and should have a chosen number of seats, and be associated with a pair of destinations (one to leave from and one to arrive at -- these might get updated after each trip), and people (to choose the bus route they want and to sit in the buses). The buses should indicate if they're full, but until then should allow people to join the bus. Build such other structure to your model as makes sense to you without becoming overly sophisticated

    So far I've come up with a people class ''' Created on Jul 7, 2013 @author: Rohan Vidyarthi, Papon Luengvarinkul '''

    class Person :
    '''This people class will allow me to make people'''

    def __init__(self, name, ID, age, location, destination):
    self.my_name = name
    self.my_ID = ID
    self.my_age = age
    self.my_location = location
    self.my_destination = destination

    def introduce_myself(self):
    return str(self.my_name + " " + str(self.my_ID) + " " + str(self.my_age) + " " + self.my_location + " to " + self.my_destination)
    def __str__(self):
    return self.my_name


    But I don't really know how i'm going to do this. Also

    I created a Bus class that has a constructor with the inputs of the bus number, where it goes, and its capacity.

    I feel like I'm not going anywhere with this and i just need like a plan to start working on this like how to plan the program out

    Continue reading...

Compartilhe esta Página