import random import time import control as control class control(): def __init__(self,tvCase="Close",tvVol=0,tvList=["TRT"],activeCh="TRT"): self.tvCase = tvCase self.tvVol = tvVol self.tvList = tvList self.activeCh = activeCh def openTv(self): if(self.tvCase == "Open"): print("Tv is already Open ! ") else: print("Tv is opening ! ") self.tvCase = "Open" def closeTv(self): if(self.tvCase == "Close"): print("Tv is already Close ! ") else: print("Tv is Closeing ! ") self.tvCase = "Close" def volControl(self): print(" '+' For Vol Up !\n '-' For Vol Down !") while True: choice = input("Enter Choice : ") if(choice == '+'): self.tvVol+=1 print(self.tvVol) elif(choice == '-'): self.tvVol -= 1 print(self.tvVol) if(self.tvVol == 0): print("SILENCE ! ") else: break def addChannel(self,channelName): print("Channel Adding..") time.sleep(1) self.tvList.append(channelName) print("Channel Has Been Added ! ") def randChannel(self): rand = random.randint(0,len(self.tvList)-1) self.activeCh = self.tvList[rand] print("Active Channel : ",self.activeCh) def __len__(self): return len(self.tvList) def __str__(self): return print(""" Tv Case : {} Channel List : {} Active Channel : {} """.format(self.tvCase,self.tvList,self.activeCh)) print(""" **** TV APP **** 1 For Open Tv ! 2 For Close Tv ! 3 For Voice Settings ! 4 For Add Channel ! 5 For Channels Count ! 6 For Random Channel ! 7 For Tv Informations ! Q For Quit ! """) while True: casee = input("Enter Choice : ") if(casee == 'Q'): print("Bye Bye ! ") break elif(casee == "1"): control.openTv() elif(casee == "2"): control.closeTv() elif(casee == "3"): control.volControl() elif(casee == "4"): chNames = input("Enter Channels with use ',' ! ") newList = chNames.split(",") for i in newList: control.addChannel(chNames) elif(casee == "5"): print(len(control)) elif(casee == "6"): control.randChannel elif(casee == "7"): print(control) else: print("ERROR ! ")