Question
I need some help with my python programming project. We had to make a program with at least 5 object classes, it must execute from
I need some help with my python programming project. We had to make a program with at least 5 object classes, it must execute from the terminal, and we're only allowed to use python standard libraries. I'm having issues while calling the functions in my classes. Please see my code below, run it on your side. Each class is giving me the " Positional argument error.
Purpose of the program: Provide user guidance on how to brew coffee using either the pour-over method, french press or flair espresso
Steps:
- user runs .py file from computer, then prompted to log in or create a new account. (Barista Class)
- user then is prompted to select a coffee brewing method. Information is then captured in a dictionary
- user then inputs a brean and roast. bean information is then captured on a dictionary
- user then inputs the roast date. Class returns feedback on coffee freshness by the parameters
- user then inputs the final brew time. User receives feedback on weather or not they hit the target
- user then is asked if they want to save the file. If yes, then brew_data.csv gets opened and new data is happened to the file
import datetime
import csv
class Barista:
"""A representation of the program login, or create a new user & password.
Attributes:
Username(string)
Lastname(string)"""
def __init__(self, username, password):
self.username = user_name
self.password = password
def verify_account():
login = False
answer = input("Do you have an account?(yes or no) ")
if answer == 'yes':#verify's user_name from directory
with open('user_log.csv', 'r') as csvfile:
csv_reader = csv.reader(csvfile)
username = input("Barista_name: ")#verify's user_name in colunmn 1
password = input("Password: ")#verify's password in column 2
for row in csv_reader:
if len(row)>0:#Make sure row is not empty or else the programwill crash
if row[0]== username and row[1] == password:
login = True
break
else:
login = False
if login == True:
print("You are now logged in!")
else:
print("Incorrect.")
exit()
else:
with open('user_log.csv', 'a',newline='') as csvfile:
username = input('Create user name >>')
password = input('Create password >>')
writer = csv.writer(csvfile, delimiter =',' )
writer.writerow([new_username,new_password])# write the data to csv
def greet_user():#greet user after log in
return "Welcome "+ username + "!"
def display_user:
return
#------Test Class Barista-------#
##Verify Barista Object or create a new Barista Object and return Welcome message##
barista1 = Barista
barista1.verify_account()
greet1 = Barista.greet_user()
class Brew:
"""Represents the information on different manual coffee brewing methods
Attributes:
Method (String)
"""
pour_over = {" grind_size ":" med_fine ", " g/ml ":" 18/280 ",
"bloom_time": "35 sec", "brew_time":"2m35sec - 3m35sec"}
french_press = {" grind_size ":" course ", " g/ml ":" 40/600 ",
"bloom_time": "1min", "brew_time":"10min"}
flair_espresso = {" grind_size ":" fine ", " g/ml ":" 15/35 ","bloom_time": "none",
"brew_time":"35sec = 45sec"}
def __init__(self, method):
self.method = method
def show_brew_info(self):
self.brew_info = brew_dict
brew_dict = {}
return brew_dict.#build a dictionary for the brew method
@classmethod
def get__method(self):
while 1:
try:
method = input("How would you like to brew your coffee?: A: Pour Over, B:French Press, C:Flair Espresso'").upper()
return self(method)
except:
print('Invalid input! please choose either "A", "B", or "C"')
continue
def method_guide(self):
if method == 'A':
brew_dict.add(method)
print(f"Guidence for Pour Over Method: {pour_over.items()}")
elif method =='B':
brew_dict.add(method)
print(f"Guidence for French Press:{french_press.items()}")
else:
brew_dict.add(method)
print(f"Guidence for Flair Espresso:{flair_espresso.items()}")
return self.method
##--------Test Class Brew--------##
brew1 = Brew().get_method()
guide1= Brew.method_guide()
class Bean_Option:
"""Represents the bean options for the brew method
Attributes:
Bean (string)
Roast (string)
"""
def __init__(self):
self.bean = input("Select a Bean: A: Columbia, B:Guatamala, C:Indonesia, D:Ethiopia, E: Costa Rica, F:Vietnam").upper()
self.roast = input("Select a roast: A: light, B: Med, C: Dark").upper
self.bean_info = {}
#Flavor profile dictionaries Key: "region_roast"Value: "flavor notes"
region = ({"Columbia_light":"floral, stone fruit",
"Columbia_med":"nuts, caramel",
"Columbia_dark":"chocolate, carmel",
"Guatamala_light":"floral, stone fruit",
"Guatamala_med":"nuts, caramel",
"Guatamala_dark":"chocolate, carmel",
"Indonesia_light":"floral, stone fruit",
"Indonesia_med":"nuts, caramel",
"Indonesia_dark":"chocolate, carmel",
"Ethiopia_light":"floral, stone fruit",
"Ethiopia_med":"nuts, caramel",
"Ethiopia_dark":"chocolate, carmel",
"Costa_Rica_light":"floral, stone fruit",
"Costa_Rica_med":"nuts, caramel",
"Costa_Rica_dark":"chocolate, carmel",
"Vietnam_light":"floral, stone fruit",
"Vietnam_med":"nuts, caramel",
"Vietnam_dark":"chocolate, carmel"})
def temp_guide(self):
if self.bean =="A" and self.roast =="A":#User selects Columbia Light Roast
self.bean_info.add(region[0])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="A" and self.roast =="B":#User selects Columbia Med Roast
self.bean_info.add(region[1])
return "reccomended temp = 202 F"
elif self.bean =="A"and self.roast =="C":#User selects Columbia Dark Roast
self.bean_info.add(region[2])
return "reccomended temp = 198 F"
elif self.bean =="B" and self.roast =="A":#User selects Guatamala Light Roast
self.bean_info.add(region[3])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="B" and self.roast =="B":
self.bean_info.add(region[4])
return "reccomended temp = 198 F"
elif self.bean =="B"and self.roast =="C":
self.bean_info.add(region[5])
return "reccomended temp = 198 F"
elif self.bean =="C" and self.roast =="A":#User selects Indonesia and Light Roast
self.bean_info.add(region[6])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="C" and self.roast =="B":
self.bean_info.add(region[7])
return "reccomended temp = 202 F"
elif self.bean =="C"and self.roast =="C":
self.bean_info.add(region[8])
return "reccomended temp = 198 F"
elif self.bean =="D" and self.roast =="A":#User selects Ethiopia Light Roast
self.bean_info.add(region[9])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="D" and self.roast =="B":
self.bean_info.add(region[10])
return "reccomended temp = 202 F"
elif self.bean =="D"and self.roast =="C":
self.bean_info.add(region[11])
return "reccomended temp = 198 F"
elif self.bean =="E" and self.roast =="A":#User selects Costa Rica Light Roast
self.bean_info.add(region[12])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="E" and self.roast =="B":
self.bean_info.add(region[13])
return "reccomended temp = 202 F"
elif self.bean =="E"and self.roast =="C":
self.bean_info.add(region[14])
return "reccomended temp = 198 F"
elif self.bean =="F" and self.roast =="A":#User selects Vietnam Light Roast
self.bean_info.add(region[15])#add first indexed item from columbia
return "reccomended temp = 207 F"#provides suggested brew temperature in F
elif self.bean =="F" and self.roast =="B":
self.bean_info.add(region[16])
return "reccomended temp = 202 F"
else:# self.bean =="F"and self.roast =="C":
self.bean_info.add(region[17])
return "reccomended temp = 198 F"
##--Test Class--#
##Create Bean Option Object and return
bean1= Bean_Option()
bean1.Bean_Option.temp_guide()
class RoastDate:
""""Represents the roast date on the bag of coffee
Atributes:
bag_date ()"""
def __init__(self, bag_date):
year = input("enter year: ")
month = input("enter month: ")
day = input("enter day: ")
self.bag_date = datetime.date({year},{month},{day})
def days_past(self, roast_date, fresh):
days_past = date.time.now() - self.bag_date
if days_past > 14and days_past < 15 :#if the roast date is above 30 days
return "days past roast date: " + days_past + "Beans are at peak freshness!"
BeanOption.bean_info.add(bag_date, "still fresh")
if days_past < 14:
return "days past roast date: " + days_past + "Beans are a few days early from peak freshness"
BeanOption.bean_info.add(bag_date, "not yet fresh")
else:
return "days past roast date: " + days_past + "Beans are beyond its peak freshness!"
BeanOption.bean_info.add(roast_date, "not longer fresh")
###-----Test Roast Date Class----#
#create object roast date and return days past
roast1 = RoastDate()
roast1.days_past()
class Feedback:
"""Represents the expected taste experience according to the the entered brew time
Atributes:
Actual_time (float)
Target_time (float)"""
def __init__results(self, actual_time = 00.00):
self.actual_time = input("Enter your finished brew_time:>>")
if method == "A":# checks if your actuals meet the target for Pour over
if self.actual_time > 2.3 and actual_time < 3.35:
return "great work! Here are the taste notes" + BeanOption()
elif self.actual_time > 3.35:
return"Uh oh! You May have over extracted! Try a courser grind setting Extended brew times have a tendancy to be bitter. here are some flavor notes of the bean " + BeanOption())
else:# if actual_time < 2.3:
return ('Oh no! You May have under extracted! Try a finer grind setting shorter brew times have a tendancy to be bland')
elif method =="B":#checks if your actuals meet the target for French Press
if self.actual_time > 10.0 and actual_time <8.30:
return "great work! Here are the tates notes " + BeanOption()
elif self.actual_time > 10.00:
return f "Uh oh! You May have over extracted! Specialty coffee from {bean_input} are delicate Beans that soak for too long have a tendancy to get over extracted here are some flavor notes of the bean " + BeanOption()
else: # if actual_time < 8.00:
return 'Oh no! You May have under extracted! \Try a fin shorter brew times have a tendancy to be bland'
elif method =="C": #Checks if your actuals meet the target for Flair Espresso
if self.actual_time > 0.35 and actual_time <0.45:
return "great work! Here are the tates notes" + BeanOption()
elif actual_time > 0.45:
return "Uh oh! You May have over extracted! Beans that soak for too long have a tendancy to get over extracted 'here are some flavor notes of the bean " + BeanOption()
else: #if actual_time < 0.35:
return 'Oh no! You May have under extracted! \Try a finer grind shorter brew times have a tendancy to be bland'
###----Test Class Feedback---##
feedback1 = Feedback()
class CSV_Writer:
"""historical record of previous brews
Atributes:
Brew_data (CSV file)
"""
def __init__(self, choice):#function used to write the brew_info, bean info, and
self.choice = input("would you like to save? (Y/N) ")
if save_file == "Y":
brew_file = open('brew_data.csv', 'w', newline ='')
with file:
# identifying header
header = ['date', 'barista', 'method', 'bean', 'roast', 'roast_date']
writer = csv.DictWriter(file, fieldnames = header)
# writing data row-wise into the csv file
writer.writeheader()
writer.writerow(date.time.now(), {Barista.user_name}, {Brew.show_brew_info()},{Bean_Option.bean_info()}, {bag_date})
def total_entries(self):
with open('brew_data.csv', 'r') as csvfile:#open file in read mode
csv_reader = csv.reader('csvfile')
return "total records to date" + (sum(1 for line in csvfile))
##---------Test DataCSVWriter------##
#add data to CSV file brew_method.csv
write1 = CSV_Writer()
write1.CSV_Writer.total_entries()
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