# Arup Guha
# 7/10/2013
# Example Class - Cell Phone
# Slightly edited on 6/4/2024
# Edited for Junior Knights on 3/1/2025

class phone:

    # Basic constructor.
    def __init__(self, minutes, storage, mycost, extraCharge):
        self.minPerMonth = minutes
        self.dataPerMonth = storage
        self.cost = mycost
        self.overMinCost = extraCharge
        self.curMin = 0
        self.data = self.dataPerMonth
        
    # Talk for convTime minutes.
    def talk(self, convTime):
        self.curMin += convTime

    # Get the bill for the month.
    def bill(self):

        # Clear out the object.
        storeMin = self.curMin
        self.curMin = 0
        self.data = self.dataPerMonth 

        # Regular bill.
        if storeMin <= self.minPerMonth:
            return self.cost

        # Overage bill
        return self.cost + self.overMinCost*(storeMin - self.minPerMonth)

    # Use data.
    def goOnline(self, info):

        # Typical case.
        if self.data >= info:
            print("You have successfully used",info,"megs of data.")
            self.data -= info

        # Ooops, you've run out of data.
        else:
            print("You do not have enough data, you only get",self.data,"megs.")
            self.data = 0

    # A string representation of the object. I kept it small.
    def __str__(self):
        return "Data left: "+str(self.data)+" Minutes used: "+str(self.curMin)

# Menu for my program.
def menu():
    print("1. Add a new phone.")
    print("2. Talk on a phone.")
    print("3. Go online on a phone.")
    print("4. Print out all phones.")
    print("5. Quit")
    choice = int(input())
    return choice

# A menu driven program that allows for multiple phone objects!
def menudriven():

    # Storage for my phones.
    myphones = []
    numPhones = 0
    
    # Get user's first selection.
    ans = menu()

    # Keep going.
    while ans != 5:

        # Create a phone, probably should call a function here, oh well!
        if ans == 1:

            # Update user.
            print("Great, you'll get a new phone. This is phone number", numPhones)
            numPhones += 1

            # Get info about new phone.
            minutes = int(input("how many minutes a month?\n"))
            data = int(input("how many megs of data?\n"))
            cost = float(input("cost per month?\n"))
            over = float(input("overage charge per min?\n"))

            # Create it and add it to our list of phones.
            myphone = phone(minutes, data, cost, over)
            myphones.append(myphone)

        # Talk some.
        elif ans == 2:
            which = int(input("Which phone do you want to talk on?\n"))
            time = int(input("How many minutes did you talk?\n"))
            myphones[which].talk(time)

        # Go online
        elif ans == 3:
            which = int(input("Which phone do you want to use data for?\n"))
            time = int(input("How many megs(integer) did you use?\n"))
            myphones[which].goOnline(time)

        # Print all.
        elif ans == 4:
            for i in range(len(myphones)):
                print(i, myphones[i])

        # Get next choice,
        ans = menu()
                            
# Run it!
menudriven()
