Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

Cafe Fred Nurk Plan

Introduction:

This program is made for ordering coffee from Fred Nurk’s cafe. In this program, users can input
their name, coffee selection, milk preference, sugar option and size preference. The program
then calculates the total cost based on the selected options and displays the bill and summary
of the order.

The Solution Requirements:

● There’s a user interface for inputting a customer's first name.


● Radio buttons for choosing coffee type (Flat White, Cappuccino, Short Black, Latte).
● Radio buttons for choosing milk type (Full Cream, Skim, Soy).
● Radio buttons for choosing sugar options (none, one, two).
● Radio buttons for choosing size (Small, Regular, Large).
● Can save the order.
● Calculation of total cost based on selected options and prices for coffee, milk, size, and
sugar
● Output the visual summary on-screen after the button is pressed.

The User Requirements:

Inputs:
● Name of customer
● Coffee choice (Flat White, Cappuccino, Short Black, Latte).
● Milk choice(Full Cream, Skim, Soy).
● Sugar choice(None, One, Two).
● Size choice(Small, Regular, Large).

Outputs:
● Displayed summary of the order.
● Total cost of the order.
● User input options
Design

Function calculate_total():
When this calculating function is called from the "Calculate my Bill" button when pressd, it gets
the inputted options from the GUI elements, calculates the total price based on those options
and updates the final result label with the order summary and total cost.

GUI Layout:
1. The elements are grouped together in the interface using frames (tk.Frame).
2. Headings and summaries are displayed on labels.
3. The customer's name can be entered into the entry boxes.
4. The options for size, sugar, milk type, and coffee type are selected using radio buttons.

Styling and Layout:


Fonts, colours, and layout functions are there to style and arrange the GUI elements for better
readability and understanding. The GUI options are arranged using pack() and pack(side="left")
to organise them in a side by side layout for better outlooks.
Justification:

pseudocode:

Start
1. Insert UI components including text fields
and radio buttons.
2. Store values from user inputs matching with
radio buttons and text fields.
3. Set up frames to organize UI components
logically.
4. Create a 'Calculate my Bill' button to call
calculation and summary button.
5. Define a function to handle the 'Calculate
my Bill' button click:
a. Get the customer's name from the input
text field using .get().
b. Extract selections for coffee type, milk
type, size, and sugar options from StringVar()
objects
c. Define dictionaries for prices
corresponding to each option.
d. Calculate the total price by matching
selections to their matching prices in
dictionaries.
e. Check if the name input is not empty, if
empty, display an error in the summary field.
f. If the name is present, compile an order
summary including the name, selected options
with their prices, and the total price.
g. Display the summary in a text field.
6. Add error handling to display issues in the
terminal or UI for debugging purposes.
7. Ensure all interactions and displays are
updated in real-time as the user interacts with
the UI components.
End

Firstly, all text fields, inputs and display fields are inserted for user input and output. Their
consists of radio buttons for the options and text field for the name and a final text field that is
‘read only’ to display the summary.

StringVar() and frames are used to define any given option and their value relevant to what the
user has inputted. The four options each save their chosen into this StringVar object for later
extraction and use.
Result label and frame are used to display our summary and fulfil the function later defined. This
is inserted into when the ‘Calculate my Bill’ button is pressed, which is above the result frame,
and is called by the function.

A function is defined that retrieves the user input for the name and selected options. The name
is an input text field, where the user can type the name and later the .get() function can extract
it. The options are all radio buttons under their relevant stringVar() variable, which later this
function extracts to calculate a price and display a summary.

The total price from getting the StringVar object is then calculated by matching the chosen
option to their defined dictionaries, which are unique for each option in terms of price. It, after
corresponding the values, calculates a total price for later display.

Just before displaying the order in a summary field, the function checks whether the input name
text field has value in it. If it does, it continues using the if-else statement, but if it doesn’t, it
displays an error message in the text field that displays the summary.

When all goes well, an order summary is displayed by stating the name, via name input .get()
function, the options with their prices and then the final price which the user is expected to pay.

Error handling and debugging are added lastly for understanding the areas that need workin on.
Any error will be displayed in the terminal as well as, if it is coded for the interface, in the
interface itself.

Processing Features

Data Dictionary

Variable Name Data Type Description Size

main Tk object Main window of the application N/A

entry_name Entry object Text entry for user's name N/A

Variable to store selected coffee


coffee_type_var StringVar object N/A
type

milk_type_var StringVar object Variable to store selected milk type N/A


size_var StringVar object Variable to store selected size N/A

Variable to store selected sugar


sugar_var StringVar object N/A
option

result_label Label object Label to display calculation results N/A

coffee_prices dict Dictionary storing coffee prices 4 items

milk_prices dict Dictionary storing milk prices 3 items

size_prices dict Dictionary storing size prices 3 items

sugar_prices dict Dictionary storing sugar prices 3 items

calculate_total function Function to calculate total price N/A

heading Label object Label for the application heading N/A

label_name Label object Label for the name entry field N/A

label_coffee_type Label object Label for the coffee type selection N/A

Radio_button1 <> 4 Radiobutton object Radio button for coffee 4 items

Radio_button5 <>7 Radiobutton object Radio button for milk 3 items

Radio_button8 <> 10 Radiobutton object Radio button for size 3 times

Radio_button11 <> 13 Radiobutton object Radio button for sugar 3 times

calculate_button Button object Button to do total calculation N/A

result_frame Frame object Frame to display calculation result N/A


The code has the following input functionality for the user:
Customer's first name: Entered in the entry_name entry box.
Coffee type: This is selected using radio buttons (coffee_type_var).
Milk type: This is selected using radio buttons (milk_type_var).
Size: This is selected using radio buttons (size_var).
Sugar option: This is selected using radio buttons (sugar_var).

Calculation of Total Cost:


The code has matching dictionaries for each radio button option, matching to those
prices that are relevant to any of the options.
It starts with total_price as 0 and increases as more prices are added through the
process
Then, it goes through the selected options and adds up their relevant prices to
total_price to produce the final price which is later displayed
If any of the selected options aren’t found in its matching dictionary, it prints an error
message in the console of python

Displaying Order Summary:


After the total prices is calculated by the function, it will display a summary with each filter option
and its price and showing the final sum, which is the addition of all of that
The summary includes the coffee type, milk type, size, sugar option and their individual prices.
The summary is displayed in the result_label label widget

Error Handling:
If the code doesnt find the selected option in its dictionary, an error message is printed in the
console

Event Handling:
The "Calculate my Bill" button calls the calculation of the total cost and the update of the result
label with the order summary.

Testing Table

Item Tested Test Data Expected Result Actual Result


Customer's
"Abijeettttt" Can input text Text input accepted
Name

Can select a coffee Able to select a coffee


Coffee Type Select "Flat White"
type type

Able to select a milk


Milk Type Select "Skim" Can select a milk type
type

Size Select "Large" Can select a size Able to select a size

Can select a sugar Able to select a sugar


Sugar Option Select "Two"
option option

All Radio Select various options Can select options for Able to select options
Buttons (13) for each category all categories for all categories

Calculation good, result


Calculate Click "Calculate my Should calculate total
displayed but no in
Button Bill" and display result
multiple lines

After clicking
Should display order Order summary and
Result Display "Calculate my Bill"
summary and total cost total cost not displayed
button

Debugging:

Print statements:
console:

Error Handling:

Without /n, my calculations were correct but were displayed in multiple lines:
Because i was correctly receiving my inputs and bill, it could only have been an
attribute issue, so i added ‘/n’. It becomes:

Evaluation:

User Interface and Input Collection:


Efficiency: The user can efficiently select their filtering options from the available radio buttons
to produce their final coffee order. All Inputs are accurately collected and stored.
Effectiveness: The design is effective because it avoids confusion and misunderstanding. The
users can quickly go through the options and be assured everything is stored

Order Processing and Calculation:


Efficiency: The code efficiently is able to process the users order based on the selected options
by matching it to the available dictionaries and ensure they map to the correct prices. After
retrieving the prices from the dictionary, it performs an efficient calculation without flaws to give
an exact bill to the user.
Effectiveness: The code accurately retrieves and calculates the final bill based on matching
dictionaries making it easier for the user and reducing any worry about pricing

Order Summary Display:


Efficiency: The coding efficiently displays a summary of the order, which has the selected
options and the total cost. It changes the result label with the order summary in real-time after
clicking the "Calculate my Bill" button. The code efficiently displays the final order summary with
the users name, all selected options with their individual pricing and final cost. The function is
called after the Clculate My Bill button is pressed and efficiently runs through the code smoothly
to give a quick final answer.
Effectiveness: The summary that is displayed is clear and gives precise overview of the
various details of the order making it easier for the user to re-evaluate.

Error Handling:
Efficiency: The code has efficient error handling to ensure that all aspects of the order are
fulfilled and any missed information is re-considered. This avoids flaws in the final calculator and
helps the viewer with his order.
Effectiveness: Because some error messages are printed to the console, there is room for
improvement when the code provides feedback to the user on the interface itself rather than the
console to enhance overall effectiveness. Putting error pop-ups or highlighting error selections
would the improve user experience.

Non-Functional Requirements:
Efficiency: The software isn’t too complex making it a good option for any device version etc;.
Errors coming due to device won’t occur as the code is basic without excess cloud-based
material and back-end.
Effectiveness: The GUI layout and design are visually attractive and easy to navigate,
enhancing user satisfaction. The software fulfils non-functional requirements related to usage,
aesthetics, and performance effectively.

You might also like