# Arup Guha
# 7/10/2013
# Example Class - Cell Phone
# Slightly edited on 6/4/2024

class CellPhone:

    minPerMonth = 500
    dataPerMonth = 2000
    data = 2000
    cost = 79
    overMinCost = 0.25
    curMin = 0

    # 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)

# One test...
def main():

    # Here's the phone plan.
    mine = CellPhone(1000, 3000, 65, .35)

    # Use the phone, print the object.
    mine.talk(35)
    mine.talk(77)
    mine.goOnline(2000)
    mine.goOnline(33)
    mine.goOnline(973)
    print(mine)

    # Now look at the amount of the bill.
    print("My first bill is",mine.bill())

    # yap, yap, yap
    for i in range(19):
        mine.talk(50)

    # Ouch!
    mine.talk(234)
    print("My second bill is",mine.bill())

main()
