0

Absolute beginner to Python and programming, I am trying to create a program where the user can add meetings and store them, kind of like a calendar.

When doing this, I've created a class Meetings, with 4 parameters (name, start_time, end_time, link)

class Meeting:

    def __init__(self, name, start_time, end_time, link):
        self.name = name
        self.start_time = start_time
        self.end_time = end_time
        self.link = link

In the app.py file I typed this:

from Meeting import Meeting


def meetings_count(meeting_count1):
    meeting_count1 += 1
    return meeting_count1


def ask_meeting(meeting_count2):
    answer = input("Do you want to add a new meeting?: ")
    if answer == "yes":
        meeting_count2 = meetings_count(meeting_count2)
        print("Number of meetings: " + str(meeting_count2))
        name = input("\nName: ")
        start_time = input("Start time: ")
        end_time = input("End time: ")
        link = input("Link: ")
        add_meeting(name, start_time, end_time, link, meeting_count2)


def add_meeting(name1, start_time1, end_time1, link1, meeting_count3):

    # code that creates something like this but instead of the line bellow,

    Meeting1 = Meeting(name1, start_time1, end_time1, link1)

    # creates an object named "Meeting" + meeting_count3
    # if that is possible, then I can store different meetings(in the form of objects)

    print("\n" + Meeting1.name)
    print(Meeting1.start_time)
    print(Meeting1.end_time)
    print(Meeting1.link + "\n")
    print("Number of meetings: " + str(meeting_count3) + "\n")
    ask_meeting(meeting_count3)


meeting_count = 0
ask_meeting(meeting_count)

I've watched all over the web for "Variable variables" and "Dictionary usage", but it is just confusing me all over because the projects have a much higher level of complexity.

EDIT: To clarify, I do know what lists and dictionaries are. My question is, when I create the first meeting, it is recognized as the object Meeting1, but when I try to create a second meeting, it will overwrite the first meeting. What I´d like to do is create objects of the class Meetings in a way that it equals:

 Meeting(meeting_count) = Meeting(name1, start_time1, end_time1, link1)

This way, the first meeting created will be the object Meeting1, the second meeting will be the object Meeting2, etc.

EDIT2: After reading your answers, I´ve understood that such a program could be coded using lists instead of classes. Thank you all for the time and patience to deal with a fool like me :D

Thank you!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
2am_Moon
  • 1
  • 1

1 Answers1

0

if you want to check your program, first of all just create a new meeting type variable: m1 = Meeting(name, start_time, end_time, link) in order to your __init__ to start first, and only than you can check how your program works.

also i will reccomend you to go through all basic data types in python such as lists dicts and etc before you try to run OOP codes.

marksman123
  • 389
  • 2
  • 11
  • Thank you for the help, this m1 variable should be placed in the file where i declare the Meeting class right? – 2am_Moon May 25 '20 at 12:43
  • @2am_Moon no, you just initialize in the end of the program, in the same lines you wrote `meeting_count = 0` – marksman123 May 25 '20 at 13:06
  • So, I was following this tutorial: https://youtu.be/rfscVS0vtbw And it doesn´t mention such thing. What is the use of such a variable? – 2am_Moon May 25 '20 at 13:07
  • @2am_Moon well, when you create a new class, you need to create a variable that is a same data type like the class you created in order to try the code youve just written. my explanation is really slim, and this subject is way more broad. ihighly reccomend you to start a course in [udemy](http://www.udemy.com) of python, because a 4 hour video on youtube will never gives you a suffiecent amount of information that you need about this subject. – marksman123 May 25 '20 at 13:12