Do My Homework / Homework Help Answers / Python Homework Help / Help with simple python database using classes

Help with simple python database using classes

Need help with this question or any other Python assignment help task?

Need help completing this. Instructions and work so far attached: Programming Assignment 5 Your work on the last project, the inventory ordering system, was so well received that your boss has asked you to write a new program for the firm. She mentions that she’s heard a lot about “Object Oriented Programming” and wants you to create a database of part’s suppliers that the company will use to source new inventory from. She mentions that there have been a lot of new entrants into the market and its important that you source the new widgets and sprockets at the best cost possible! From speaking with her you realize that you’ll need three new class definitions – a class that models a supplier, a class that represents a part, and class that will contain information about all these suppliers. The parts class will need to contain the following information: 1. Part name 2. Part cost The parts class will need to contain the following methods: 1. An init method that lets the user set the name and cost of the part The supplier class will need to contain the following information: 1. The company name 2. A list of the parts the company supplies The supplier class will need the following methods: 1. An init method to set the company name 2. A method that lets the user add a part to the list of parts a company supplies 3. A method that takes a part argument and returns the cost of that part. 4. A method that takes a part argument and returns a Boolean if the part is supplied by the company (True if it does, False if it does not). The database class will need the following data: 1. A list of suppliers The database class will need the following methods: 1. An init method to initialize the database 2. A method to add a supplier 3. A method to find the lowest cost for a part. The input will be a part name, and the output will be two values: the name of the supplier, and the cost. If the part is not sold by any suppliers, return False, False. Unlike in other programs – you do not need to write the code for user input, input validation, or output – you need only to write the classes! The company has supplied the program to load in the data and get the data from the classes, you need only to define the classes (and test with the supplied program of course)! Sample Input/Output Enter supplier name, or quit to exit: World Parts, Inc Part info should be entered in the following format: name, price Enter part info, or quit to exit: gizmo, 1.99 Enter part info, or quit to exit: sprocket, 3.12 Enter part info, or quit to exit: quit Enter supplier name, or quit to exit: ABC Manufacturing Part info should be entered in the following format: name, price Enter part info, or quit to exit: sprocket, 3.09 Enter part info, or quit to exit: gizmo, 2.34 Enter part info, or quit to exit: dodad, 13.99 Enter part info, or quit to exit: quit Enter supplier name, or quit to exit: quit Supplier database complete! Please enter in a part name or quit to exit: gizmo Part gizmo is available for the best price at World Parts, Inc. Price: $1.99 Please enter in a part name or quit to exit: sprocket Part sprocket is available for the best price at ABC Manufacturing. Price: $3.09 Please enter in a part name or quit to exit: dodad Part dodad is available for the best price at ABC Manufacturing. Price: $13.99 Please enter in a part name or quit to exit: quit Thank you for using the price database! Additional requirements 1. You MUST use modules, you need to write your 3 classes in 3 separate Python files named database.py, part.py and supplier.py 2. Do NOT modify the supplied Python code – I will test your files with my own Python code – if you have to change the provided Python code to get your classes to work, you’ll lose points. 3. Submit only the 3 python files – part.py, supplier.py and database.py 4. Each Python file must have a program header! Tips 1. The provided code does all the input/output for this program. You only need to write the code for the 3 classes. 2. Some of the methods for the 3 classes need to be of a specific format or the supplied program will not work – these are the init methods for Suppler and Database, and add_part, add_supplier, and find_part. Make sure you have those methods defined in your program and that their signature matches what the provided code expects. 3. Write the classes from simple to more complex – start with Part, then Supplier, then Database.
Additional Instructions:
assignment5.txt blah import database import supplier import part supplier_database = database.Database() while True: data = input("Enter supplier name, or quit to exit: ") if data == "quit": break s = supplier.Supplier(data) print("Part info should be entered in the following format: name, price") while True: part_info = input("Enter part info, or quit to exit: ") if part_info == "quit": print() break try: name, price = part_info.split(",") price = float(price) except: print("Error input - Part info should be entered in the following format: name, price - please try again") continue s.add_part(name, price) supplier_database.add_supplier(s) print("\n\nSupplier database complete!\n") while True: data = input("Please enter in a part name or quit to exit: ") if data == "quit": break supplier, price = supplier_database.find_part(data) if supplier == False: print("Error part does not exist in database") else: print(f"Part {data} is available for the best price at {supplier}. Price: ${price:.2f}") print("\nThank you for using the price database!") database.txt blah import database import supplier import part supplier_database = database.Database() while True: data = input("Enter supplier name, or quit to exit: ") if data == "quit": break s = supplier.Supplier(data) print("Part info should be entered in the following format: name, price") while True: part_info = input("Enter part info, or quit to exit: ") if part_info == "quit": print() break try: name, price = part_info.split(",") price = float(price) except: print("Error input - Part info should be entered in the following format: name, price - please try again") continue s.add_part(name, price) supplier_database.add_supplier(s) print("\n\nSupplier database complete!\n") while True: data = input("Please enter in a part name or quit to exit: ") if data == "quit": break supplier, price = supplier_database.find_part(data) if supplier == False: print("Error part does not exist in database") else: print(f"Part {data} is available for the best price at {supplier}. Price: ${price:.2f}") print("\nThank you for using the price database!") part.txt blah class Part: print("parts") def __init__(self, part_name, part_cost): self.part_name = part_name self.part_cost = part_cost def get_price(self, name): return self.part_cost supplier.txt blah import part class Supplier(): print("suppliers") def __init__(self, inputdata): self.company_name = inputdata self.parts_list = [] def add_part(self, name, price): print("add part") part.Part(name,price) self.parts_list.append(name) def get_part(self, part_name): if part_name in self.parts_list: return part.Part.get_price(part_name) def get_part_avail(self, part_name): if part_name in self.parts_list: return True else: return False def __str__(self): return "mysupplier"
Programming Assignment 5 Your work on the last project, the inventory ordering system, was so well received that your boss has asked you to write a new program for the firm. She mentions that she’s heard a lot about “Object Oriented Programming” and wants you to create a database of part’s suppliers that the company will use to source new inventory from. She mentions that there have been a lot of new entrants into the market and its important that you source the new widgets and sprockets at the best cost possible! From speaking with her you realize that you’ll need three new class definitions – a class that models a supplier, a class that represents a part, and class that will contain information about all these suppliers. The parts class will need to contain the following information: 1. Part name 2. Part cost The parts class will need to contain the following methods: 1. An init method that lets the user set the name and cost of the part The supplier class will need to contain the following information: 1. The company name 2. A list of the parts the company supplies The supplier class will need the following methods: 1. An init method to set the company name 2. A method that lets the user add a part to the list of parts a company supplies 3. A method that takes a part argument and returns the cost of that part. 4. A method that takes a part argument and returns a Boolean if the part is supplied by the company (True if it does, False if it does not). The database class will need the following data: 1. A list of suppliers The database class will need the following methods: 1. An init method to initialize the database 2. A method to add a supplier 3. A method to find the lowest cost for a part. The input will be a part name, and the output will be two values: the name of the supplier, and the cost. If the part is not sold by any suppliers, return False, False. Unlike in other programs – you do not need to write the code for user input, input validation, or output – you need only to write the classes! The company has supplied the program to load in the data and get the data from the classes, you need only to define the classes (and test with the supplied program of course)! Sample Input/Output Enter supplier name, or quit to exit: World Parts, Inc Part info should be entered in the following format: name, price Enter part info, or quit to exit: gizmo, 1.99 Enter part info, or quit to exit: sprocket, 3.12 Enter part info, or quit to exit: quit Enter supplier name, or quit to exit: ABC Manufacturing Part info should be entered in the following format: name, price Enter part info, or quit to exit: sprocket, 3.09 Enter part info, or quit to exit: gizmo, 2.34 Enter part info, or quit to exit: dodad, 13.99 Enter part info, or quit to exit: quit Enter supplier name, or quit to exit: quit Supplier database complete! Please enter in a part name or quit to exit: gizmo Part gizmo is available for the best price at World Parts, Inc. Price: $1.99 Please enter in a part name or quit to exit: sprocket Part sprocket is available for the best price at ABC Manufacturing. Price: $3.09 Please enter in a part name or quit to exit: dodad Part dodad is available for the best price at ABC Manufacturing. Price: $13.99 Please enter in a part name or quit to exit: quit Thank you for using the price database! Additional requirements 1. You MUST use modules, you need to write your 3 classes in 3 separate Python files named database.py, part.py and supplier.py 2. Do NOT modify the supplied Python code – I will test your files with my own Python code – if you have to change the provided Python code to get your classes to work, you’ll lose points. 3. Submit only the 3 python files – part.py, supplier.py and database.py 4. Each Python file must have a program header! Tips 1. The provided code does all the input/output for this program. You only need to write the code for the 3 classes. 2. Some of the methods for the 3 classes need to be of a specific format or the supplied program will not work – these are the init methods for Suppler and Database, and add_part, add_supplier, and find_part. Make sure you have those methods defined in your program and that their signature matches what the provided code expects. 3. Write the classes from simple to more complex – start with Part, then Supplier, then Database.
There are no answers to this question.
Login to buy an answer or post yours. You can also vote on other others

Get Help With a similar task to - Help with simple python database using classes

Related Questions

Similar orders to Help with simple python database using classes
188
Views
2
Answers
284
Views
2
Answers
Popular Services
Tutlance Experts offer help in a wide range of topics. Here are some of our top services: