Question

I am trying to finish the code below. class DVD: def __init__(self, title, dvd_type, cost): self.title = title self.dvd_type = dvd_type self.cost = cost def setTitle(self, netTitle): self.title = newT...

I am trying to finish the code below.

class DVD: def __init__(self, title, dvd_type, cost): self.title = title self.dvd_type = dvd_type self.cost = cost def setTitle(self, netTitle): self.title = newTitle def getTitle(self): return self.title def getType(self): return self.dvd_type def getCost(self): return self.cost def setCost(self, newCost): self.cost = newCost def setType(self, newdvd_Type): validTypes = ['Game', 'Word', 'Compiler', 'Spreadsheet', 'dBase', 'Presentation'] while True: self.dvd_type = input( 'Please enter the valid type: (Game, Word, Compiler, Spreadsheet, dBase, Presentation)') if self.dvd_type() not in validTypes: print( 'Incorrect type, please enter from the following choices: ' '(Game, Word, Compiler, Spreadsheet, dBase, Presentation)') continue else: self.dvd_type = newdvd_Type break def loadInformation(self): self.__title = input('Enter a title of the DVD') self.__dvdtype = input('Enter the type of DVD') self.__cost = input('Please enter the cost') def listValidDVDTypes(self): print ( "We only accept: 'Game', 'Word,' 'Compiler', 'Spreadsheet', 'dBase', and 'Presentation' as the DVD Typers") def Display_DVD_Information(dvds): for obj in dvds: print (obj.title) print (obj.dvd_type) print (obj.cost) def DisplayTotalAndAverageCosts(dvds): add = 0 for obj in dvds: add += obj.cost print (obj.cost) avg = add / len(dvds) print ('Average cost: ', avg) def ChangeDVD(A_DVD): print ('DVD Title is: ', A_DVD.title) in1 = input('Do you want to change title (y/n): ') if in1 in ['y', 'Y']: title = input('Please enter a title: ') A_DVD.title = title else: pass print ('DVD type is ', A_DVD.dvd_type) in2 = input('Do you wan to change type (y/n): ') if in2 in ['y', 'Y']: validTypes = ['Game', 'Word', 'Compiler', 'Spreadsheet', 'dBase', 'Presentation'] while True: dvd_type = input('Please enter valid type: (Game,Word,Compiler,Spreadsheet,dBase,Presentation)') if dvd_type.title() not in validTypes: print( 'Incorrect type, please enter from the following choices: ' '(Game,Word,Compiler,Spreadsheet,dBase,Presentation)') continue else: A_DVD.type = dvd_type break else: pass print ('DVD cost is ', A_DVD.cost) in3 = input('Do you want to change cost (y/n):') if in3 in ['y', 'Y']: cost = int(input('please enter the cost: ')) A_DVD.cost = cost else: pass def movies(): list = [] dvd1 = DVD('Madden 19', 'Game', 55) dvd2 = DVD('MLB 2019', 'Game', 66) dvd3 = DVD('NBA 2K19 ', 'Game', 75) list.append(dvd1) list.append(dvd2) list.append(dvd3) DVD.Display_DVD_Information(list) DVD.DisplayTotalAndAverageCost(list) DVD.ChangeDVD(dvd1) DVD.ChangeDVD(dvd2) DVD.ChangeDVD(dvd3) DVD.Display_DVD_Information(list) DVD.DisplayTotalAndAverageCosts(list) movies()

I could use the help.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#Python code

#for currency format
import locale
locale.setlocale( locale.LC_ALL, '' )
class DVD:
def __init__(self, title, dvd_type, cost):
self.title = title
self.dvd_type = dvd_type
self.cost = cost
def setTitle(self, newTitle):
self.title = newTitle
def getTitle(self):
return self.title
def getType(self):
return self.dvd_type
def getCost(self):
return self.cost
def setCost(self, newCost):
self.cost = newCost
def setType(self, newdvd_Type):
validTypes = ['Game', 'Word', 'Compiler', 'Spreadsheet', 'Dbase', 'Presentation']
while True:
self.dvd_type = input( 'Please enter the valid type: (Game, Word, Compiler, Spreadsheet, Dbase, Presentation)')
if self.dvd_type() not in validTypes:
print( 'Incorrect type, please enter from the following choices: ' '(Game, Word, Compiler, Spreadsheet, Dbase, Presentation)')
continue
else:
self.dvd_type = newdvd_Type
break
def loadInformation(self):
self.title= input('Enter a title of the DVD')
self.dvd_type = input('Enter the type of DVD')
self.cost = input('Please enter the cost')
def listValidDVDTypes(self):
print ( "We only accept: 'Game', 'Word,' 'Compiler', 'Spreadsheet', 'Dbase', and 'Presentation' as the DVD Typers")
def Display_DVD_Information(dvds):
for obj in dvds:
print ("DVD Title: ",obj.title)
print ("DVD Type: ",obj.dvd_type)
print ("DVD Cost: ",locale.currency(obj.cost,grouping=True) )
def DisplayTotalAndAverageCosts(dvds):
add = 0
for obj in dvds:
add += obj.cost
print ("Total DVD Cost: ",locale.currency(add,grouping= True))
avg = add / len(dvds)
print ('Average cost: ', locale.currency(avg,grouping= True))
def ChangeDVD(A_DVD):
print ('DVD Title is: ', A_DVD.title)
in1 = input('Do you want to change title (y/n): ')
if in1 in ['y', 'Y']:
title = input('Please enter a title: ')
A_DVD.title = title
else:
pass
print ('DVD type is ', A_DVD.dvd_type)
in2 = input('Do you wan to change type (y/n): ')
if in2 in ['y', 'Y']:
validTypes = ['Game', 'Word', 'Compiler', 'Spreadsheet', 'Dbase', 'Presentation']
while True:
dvd_type = input('Please enter valid type: (Game,Word,Compiler,Spreadsheet,Dbase,Presentation): ')
if dvd_type.title() not in validTypes:
print( 'Incorrect type, please enter from the following choices: ' '(Game,Word,Compiler,Spreadsheet,Dbase,Presentation)')
continue
else:
A_DVD.dvd_type = dvd_type .title()
break
  
print ('DVD cost is ', locale.currency(A_DVD.cost,grouping= True))
in3 = input('Do you want to change cost (y/n):')
if in3 in ['y', 'Y']:
cost = int(input('please enter the cost: '))
A_DVD.cost = cost
else:
pass
def movies():
list = []
dvd1 = DVD('Madden 19', 'Game', 55)
dvd2 = DVD('MLB 2019', 'Game', 66)
dvd3 = DVD('NBA 2K19 ', 'Game', 75)
list.append(dvd1)
list.append(dvd2)
list.append(dvd3)
DVD.Display_DVD_Information(list)
DVD.DisplayTotalAndAverageCosts(list)
DVD.listValidDVDTypes(dvd1)
DVD.ChangeDVD(dvd1)
DVD.listValidDVDTypes(dvd2)
DVD.ChangeDVD(dvd2)
DVD.listValidDVDTypes(dvd3)
DVD.ChangeDVD(dvd3)
print("Infromation after modifications: ")
DVD.Display_DVD_Information(list)
DVD.DisplayTotalAndAverageCosts(list)
movies()

#Screen shots for indentation help

#for currency format import locale locale.setlocale( locale.LC ALL,) Eclass DVD: def-init-(self, title, self.title-title dv

self.cost ǐnput(.Please enter the cost) def listValidDVDTypes (self): print ( We only accept: .Game, Word, ·Compiler., .S

continue else: ADVD.dvd_type-dvd type .title() break print (DVD cost is , locale.currency (A DVD.cost,grouping- True)) in3

#output

DVD Title: Madden 19 DVD Type: Game DVD Cost: $55.00 Title: MLB 2019 Type Game DVD Cost: $66.00 DVD Title: NBA 2K19 DVD Type:

//if you need any help regarding this solution ............ please leave a comment ............ thanks............

Add a comment
Know the answer?
Add Answer to:
I am trying to finish the code below. class DVD: def __init__(self, title, dvd_type, cost): self.title = title self.dvd_type = dvd_type self.cost = cost def setTitle(self, netTitle): self.title = newT...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python Problem Hello i am trying to finish this code it does not save guesses or...

    Python Problem Hello i am trying to finish this code it does not save guesses or count wrong guesses. When printing hman it needs to only show _ and letters together. For example if the word is amazing and guess=a it must print a_a_ _ _ _ not a_ _ _ _ and _a_ _ _ separately or with spaces. The guess has a maximum of 8 wrong guesses so for every wrong guess the game must count it if...

  • # Declaring Node class class Node: def __init__(self, node_address): self.address = node_address self.next = None #...

    # Declaring Node class class Node: def __init__(self, node_address): self.address = node_address self.next = None # Creating empty list forwarding_list = Node() # Recurssive Method for add address def addAddress(node): if node.address == old_address: # Address is same if node.next == None: # Next is None node.next = Node(new_address) # Add Next print("Added") # Addedd else: # Next is not none print("Entry already exists") elif node.next != None: # Check Next Node addAddress(node.next, old_address, new_address) def addEntry(forwarding_list):# Method for add...

  • COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild):...

    COMPLETE THE _CONSTRUCT() AND CONSTRUCTTREE() FUNCTIONS class expressionTree:    class treeNode: def __init__(self, value, lchild, rchild): self.value, self.lchild, self.rchild = value, lchild, rchild def __init__(self): self.treeRoot = None    #utility functions for constructTree def mask(self, s): nestLevel = 0 masked = list(s) for i in range(len(s)): if s[i]==")": nestLevel -=1 elif s[i]=="(": nestLevel += 1 if nestLevel>0 and not (s[i]=="(" and nestLevel==1): masked[i]=" " return "".join(masked) def isNumber(self, expr): mys=s.strip() if len(mys)==0 or not isinstance(mys, str): print("type mismatch error: isNumber")...

  • Previous code: class BinarySearchTree: def __init__(self, data): self.data = data self.left = None self.right = None de...

    Previous code: class BinarySearchTree: def __init__(self, data): self.data = data self.left = None self.right = None def search(self, find_data): if self.data == find_data: return self elif find_data < self.data and self.left != None: return self.left.search(find_data) elif find_data > self.data and self.right != None: return self.right.search(find_data) else: return None    def get_left(self): return self.left def get_right(self): return self.right def set_left(self, tree): self.left = tree def set_right(self, tree): self.right = tree def set_data(self, data): self.data = data def get_data(self): return self.data def traverse(root,order):...

  • THIS IS THE CODE I AM TRYING TO RUN code # def main():       #Reading a as...

    THIS IS THE CODE I AM TRYING TO RUN code # def main():       #Reading a as an integer       a = int(input("Enter value for a: "))       #reading b as an interger       b = int(input("Enter value for b: "))       #reading n as an integer       n = int(input("Enter value for n: "))       # displaying if a and b are congruent modulo n, this is True if a and b       #both returns same remainder when divided by n       if a % n == b...

  • Please provide pseudocode for the following python program: class Student: def t(self,m1, m2, m3): tot= m1+m2+m3;...

    Please provide pseudocode for the following python program: class Student: def t(self,m1, m2, m3): tot= m1+m2+m3; average = tot/3; return average class Grade(Student): def gr(self,av): if av>90: print('A grade') elif (av<90) and (av>70): print('B grade') elif (av<70) and (av>50): print('C grade') else: print('No grade') print ("Grade System!\n") s=Student(); repeat='y' while repeat=='y': a=int(input('Enter 1st subject Grade:')) b=int(input('Enter 2nd subject Grade:')) c=int(input('Enter 3rd subject Grade:')) aver=s.t(a,b,c); g=Grade(); g.gr(aver); repeat=input("Do you want to repeat y/n=")

  • Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk()...

    Here is my code for minesweeper in python and it has something wrong. Could you please help me to fix it? import tkinter as tk import random class Minesweeper: def __init__(self): self.main = tk.Tk() self.main.title("mine sweeper") self.define_widgets() self.mines = random.sample( [(i,j) for i in range(25) for j in range(50) ],self.CustomizeNumberOfMines()) print(self.mines) self.main.mainloop() self.CustomizeNumberOfMines() def define_widgets(self): """ Define a canvas object, populate it with squares and possible texts """ self.canvas = tk.Canvas(self.main, width = 1002, height=502, bg="#f0f0f0") self.canvas.grid(row=0, column=0) self.boxes =...

  • I need to complete the code by implementing the min function and the alpha betta pruning...

    I need to complete the code by implementing the min function and the alpha betta pruning in order to complete the tic tac toe game using pything. code: # -*- coding: utf-8 -*- """ Created on: @author: """ import random from collections import namedtuple GameState = namedtuple('GameState', 'to_move, utility, board, moves') infinity = float('inf') game_result = { 1:"Player 1 Wins", -1:"Player 2 Wins", 0:"It is a Tie" } class Game: """To create a game, subclass this class and implement actions,...

  • how do I write this code without the imports? I don't know what pickle is or...

    how do I write this code without the imports? I don't know what pickle is or os.path import pickle # to save and load history (as binary objects) import os.path #to check if file exists # character value mapping values = {'A': 1, 'B': 3, 'C': 3, 'D': 2, 'E': 1, 'F': 4, 'G': 2, 'H': 4, 'I': 1, 'J': 8, 'K': 5, 'L': 1, 'M': 3, 'N': 1, 'O': 1, 'P': 3, 'Q': 10, 'R': 1, ' S': 1,...

  • I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to...

    I'm trying to sort a list of students from a text file in python(3.7) with three separate sorting functions (Bubble, selection, insert) I'm not sure to why as its not working I'm going to guess its because I'm not using the swap function I built. Every time I run it though I get an error that says the following Traceback (most recent call last): File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 146, in <module> main() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py", line 122, in main studentArray.gpaSort() File "C:/Users/tkoto/Desktop/SearchAndSortLab.py",...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT