You are on page 1of 41

Carpenter Quotation

System

Flowchart + Debugging-
Dawid P.

Programming + GUI +
Google Doc -
Nakshatr V.

1
A GCSE computer science OCR
project

Pages:

Section 1:......................................................................3
The Scenario.................................................................3
Section 2:......................................................................5
The Programming.........................................................5
Section 2A:....................................................................6
Setting Constants.........................................................6
Section 2B:....................................................................7
Adding Customers.......................................................7
Section 2C:..................................................................14
Selecting Customers..................................................14
Section 2D:..................................................................16
Integration of Functions into the Finalised Code....16
Section 3:....................................................................22
Tkinter GUI..................................................................22
Section 4:....................................................................34
‘Program in Action’....................................................34

2
Section 1:
The Scenario

“John is a local decorator who lives in


Brentford. He has asked you to keep track of his
jobs and the costs involved. He lays carpets for
customers. He has to give his customers
accurate quotes after he has taken
measurements. You will need to develop a
computer system for him using Python that will
help him to do this”

3
4
Section 2:
The Programming
(Logic of the base program)

Using SECTION 4 (flowchart 1), it is


possible to create code for the base
program.

This section will be split into


subsections. Each subsection is a
building block that makes up the
whole program by breaking them
down into smaller tasks
(decomposition).

Section 2A - Setting constants

5
Section 2B - Adding Customer
Section 2C - Selecting Customer
Section 2D - Integration of functions
in finalised code
Section 2A:
Setting Constants

This section basically assigns values


of each material into constants.

(Constants: A location in memory


which cannot be changed as the
program is running)

The table of data:

6
Section 2B:
Adding Customers

In this section, the program takes


inputs from the user and does so
until all info is taken, which is then
added together to find the total
overall cost. All this code though, is
set to function, as it is more efficient
to pluck in the function into the
IF/ELSE statement used later on in
this project, when addressing other
components, like GUI.

7
(efficiency in computers: the number
of computational resources used by an
algorithm and time taken by an
algorithm to produce the desired
result.)
Part 1
Gathering customer details

This part of the program:

1. Creates a function
‘add_customer’
2. Tells the user that they will
write to the file

8
3. Inputs customer’s details
(name, street, town, postcode)
which are used later on when
assigning values into final output.

Part 2
Gathering Job Details

This part of the program:

1. Inputs all dimensions for


room
2. Calculates room area (which
will be used for final output)
9
3. Asks user for which underlay
material they will need for job
(line 30)

(For feature 3, there will be an IF statement in Part 3


which uses it)

Part 3
Calculations for each type of
underlay
(This part will be split into 3.1-3.3)

3.1
“First Step”

10
(When stating features of these sections, the
line number of the code is often referred to)
This part of the program:

1. States that ‘first step’ will be used.


2. Sets a constant for ‘hourly_rate’

3. Calculates ‘hours_req’(- uired)

4. Calculates John’s labour costs

5. Calculates the overall cost for

underlay (line 43)

11
6. Calculates the overall cost for the
carpet (line 44)
7. Calculates the total price for the

whole job, by adding all previously


calculated values together (line 46)
8. Outputs to user the grand total

(line 48)
9. Sets the whole IF statement into

‘first step’ which will be used later


on for GUI program (line 49)

3.2
“Monarch”

12
This part of the program:

REPEATS THE SAME EXACT STEPS


FROM 3.1, BUT LINE NUMBERS
DIFFER, WHICH WILL BE EDITED
BELOW

10. Calculates the overall cost for underlay (line 55)


11. Calculates the overall cost for the carpet (line 56)
Calculates the total price for the whole job, by
12.
adding all previously calculated values together (line
57)
13. Outputs to user the grand total (line 58)
14. Sets the whole IF statement into ‘first step’ which will be used later
on for GUI program (line 59)

3.3
“Royal”

13
This part of the program:

REPEATS THE SAME EXACT STEPS


FROM 3.1, BUT LINE NUMBERS
DIFFER, WHICH WILL BE EDITED
BELOW

15. Calculates the overall cost for underlay (line 66)


16. Calculates the overall cost for the carpet (line 67)
Calculates the total price for the whole job, by
17.
adding all previously calculated values together (line
68)
18. Outputs to user the grand total (line 69)

Section 2C:
Selecting Customers

In this section, the program takes


the first name of the user and
performs a linear search through all
the names in the TXT file until a

14
block under the person with the first
name of input is found. This is then
outputted back to the user but in
addition, it also outputs the last
name of the person, creating a full
name.
(INPUT EXAMPLE: [Nakshatr])
(OUTPUT EXAMPLE: [Nakshatr
Velagapudi])
(OUTPUT EXAMPLE 2: [No such
customer in file])
(To note: this program only outputs user first in
file, even if same first name is present later on)

This part of the program:

15
1. Asks user to input first name of
user
2. Reads the .txt file (as ‘f’)
3. For each line in the list [lines],
it iterates in FOR loops to perform
PART 4.
4. If the users input (first name) is
valid in the line, it prints the whole
line (Which is the whole name)
5. Otherwise (else), it outputs the
fact that there isn’t ‘such customer
in file’
Section 2D:
Integration of Functions into the
Finalised Code

Using all the functions from Sections


2A, 2B and 2C, we now implement
these into the final code. This is

16
ultimately done by integrating these
functions within the conditional
(IF/ELSE) statements. However, to
ensure seamless operation, we first
establish sections for the user to
read data. This section will be
separate to the IF/ELSE statements,
but technically falls into the same
category as its primary purpose is
to enhance user experience during
data reading.

(Section 2D - For Seamless Reading)

17
(This section falls into the function
‘add_customer’)

This part of the program:

1. Outputs user info accordingly


by setting a uniform order in the
TXT file by doing following steps.
2. Sets the name of section (for
example: ‘Name’) and
concatenates its value, all in a TXT
file
EXAMPLE OUTPUT:

18
19
Section 2D: Integration of functions
(Final subsection for Section 2)

Step 1:
Ask users if they wish to ADD a new
customer, or SELECT an existing
customer.

If the user chooses to add a new


customer:

The code will then initiate the


‘add_customer()’ function, and then
store info inputted by the user into the
quotations.txt file.

20
Step 2:
If the user chooses to select a new
customer:

The program will first ask the user to


input the name of the user. Then, the
program opens the .txt file in the READ
MODE. If the program finds a first
name identical to the one selected by
the user, the program prints the whole
line in which the first name is located
within. If not found, however, the
program outputs ‘No such customer in
the file’.

21
Section 3:
Tkinter GUI

This section shows the program


required to create a GUI using Tkinter’s
functional messagebox. The final
program follows the foundation of the
logic built throughout Section 1 and
Section 2.

The GUI:

22
To Note:
This GUI program follows the same
logic, but just transforms into an
interface.

Step 1:
Import tkinter

23
Messagebox is used for this program,
as it is much easier to operate and in-
built to tkinter.

Step 2:
Variables from logic program/also
referred to as ‘main.py’

Step 3:

24
Using entry.get() to create entry boxes
and implements data from the
‘customer_add’ function in ‘main.py’

Entry boxes allow users to input in data


(stores input in corresponding variable)
Step 4:
Create a variable for the calculator of
the area of the room

Step 5:
Copy paste in the same if/else/elif
statements used in ‘main.py’ for each
underlay material

25
Step 6:
Copy paste the formatting of the
quotation.txt file into GUI program
(because even for GUI project, txt file is
required to store data)

26
Step 7:
Copy paste the file organisation from
‘main.py’

This creates a gap between each


customer in the .txt file
Step 8:
Output a message from messagebox
for when the user clicks ‘submit’ once
their inputting is done.

27
(“Information” in that line refers to the
heading of the messagebox that pops
up)
Step 9:
Allow user to choose either to add
customer into the file or select out
from. (Note: the user does not input this
into the GUi file, but rather into the
console, which then redirects user to
GUI or returns selected name from txt
file

28
Step 9.5:
If user chooses to add customer, then
they are redirected to messagebox

Step 10:
Create label entry sections for all
details required to be inputted.

29
30
(Label refers to subheadings over the
entry box. Pack refers to ‘print[ing]’)

Step 11:
Allows user to select the underlay type
using the built in function ‘OptionMenu’

This basically adds this into the


window:

Step 13:
Create a submit button, for the user,
when they’re done entering customer
information.

Does so, using:

31
- tk.button() function where it
generates a button (text is added)
- Packed directly into messagebox,
below entry boxes

Step 12:
Use tkinter function: ‘.mainloop()’ so
that the program will run for the user
until the user decides to quit program

Step 14:
Copy paste the ‘select’ function from
main.py, as the function remains the
same regardless of GUI

32
(This is the same program that is used
in Section 2D: Step 2)

33
Section 4:
‘Program in Action’

Now that the code for the main.py and


the integration of that into GUI is
shown, this short section will now show
the program in action.

34
Firstly, the program will output 2
choices for the user:
To add customer
To select customer

This is displayed in the console.

The user can choose to type in:


‘Add’
or
‘Select’

35
‘Add’

Once the user inputs add, the GUI will


output.

The user is then given entry boxes to


type info about customers.

36
For example:

37
Once the user clicks ‘Submit’, an
Information Box pops up:

38
Now, all this information is then
transferred to ‘quoatations.txt’ file,
where it is stored

‘Select’
39
If the user, in the console, chooses
‘select’, then they remain in the console.

(for this example, the name that is


stored in the .txt file will be used)

The program then searches through the


txt file and outputs the first ‘Nalshatr’
in the file. When found, it outputs first
name and surname.

40
If there is no such customer in the txt
file, then, it outputs so, and breaks the
program.

The End of the Google Doc.

41

You might also like