Professional Documents
Culture Documents
Cleint 1
Cleint 1
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.
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.
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
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
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
All Radio Select various options Can select options for Able to select options
Buttons (13) for each category all categories for all categories
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:
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.