Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Show me the steps to solve in python This Milestone uses incremental programming. The autograder's unit tests will test each method individually ( with the
Show me the steps to solve in python
This Milestone uses incremental programming. The autograder's unit tests will test each method individually with the exception of Step s database setup methods, which will all be tested together independent of every other method. It is recommended to submit the program after each major step or even during a major step so as to ensure the implemented methods each function properly.
The following is the description of the dataset for the database, along with a full specification list and steps of what should be implemented in this Milestone program.
Dataset Description
A database of two tables will be initialized with two sets of data. The datasets for the database are provided in tabseparated value tsv files: menu.tsv and user.tsv The first row of the tsv files contains the header, which contain the column names, while subsequent rows contain the values of each column. The description of the dataset for each table is as follows:
menu table menutsv
category type TEXT, category of food item
itemname type TEXT, name of food item
description type TEXT, description of food item
price type DECIMAL price of food item
preptime type INTEGER, time required to prepare the food item in minutes
available type INTEGER, availability of food item in daily menu available, unavailable
user table usertsv
username type TEXT, username of user
accounttype type TEXT, type of user account admin or customer
firstname type TEXT, first name of user
lastname type TEXT, last name of user
email type TEXT, email address of user
phonenumber type TEXT, phone number of user
password type TEXT, password of user
employeeid type TEXT, employee ID of admin user
creditcardnumber type TEXT, credit card number of customer user
creditcardexpdate type TEXT, expiration date of credit card of customer user
billingaddress type TEXT, credit card billing address of customer user
rewardpoints type INTEGER, reward points earned by customer user
orderhistory type INTEGER, receipt number of last order by customer user
Step : Implement database setup methods in DbManager.py
DbManager.py contains class DbManager which allows the food vendor to create and access the database. Implement the following attributes and methods for class DbManager:
Attributes
Connection conn Connection object that, once connected, will be used throughout the program.
Instance methods
Database Setup Methods
connect
Establishes a connection to an inmemory database.
disconnect
Disconnects from the existing database.
createmenutabledatafile
Reads a tsv file and creates a table named menu.
Calls insertmenu to insert individual entries to the table.
insertmenumenu
Reads a menu tuple containing the column values of a menu entry category itemname, description, price, preptime, availability
Inserts an entry into the menu table with column values listed in the parameter.
createusertabledatafile
Reads a tsv file and creates a table named user.
Calls insertuser to insert individual entries into the table.
Step : Implement basic FoodVendor.py
FoodVendor.py contains class FoodVendor which controls the overall ordering system. FoodVendor.py will also be where a main method can be implemented to test the functionality of the program. FoodVendor.py has the following specifications:
Attributes
DbManager db DbManager object that allows access to a database.
Instance methods
initialize
Instantiates a new DbManager object.
Connects to the database.
Creates menu and user tables in the database.
Step : Implement userrelated methods in DbManager.py
In DbManager.py implement the following methods relating to the user table:
Userrelated Methods
insertuseruser
Reads a user a tuple containing the column values of a user entry username, account, firstname, lastname, email, phonenum, password, emId, cardnum, carddate, address, points, history
Inserts an entry into the user table with the column values listed in the parameter.
updatecustomerrewardsname value
Sets a user's whose name equals parameter name reward points equal to parameter value.
updatecustomerhistoryname value
Sets a user's whose name equals parameter name order history with parameter value.
isuserexistusername
Returns True if a user with name equal to parameter username exists in the database, otherwise returns False.
deleteuserusername
Removes entry of a user with name equal to parameter username from the database.
import csv
import sqlite
import os
from sqlite import Error
from os import path
class DbManager:
def initself conn:
self.conn None
def connectself:
self.conn sqliteconnect:memory:
def createmenutableself datafile:
self.connect
cursor self.conn.cursor
cursor.execute def connectself:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started