PETER'S PETROL PUMPS- MODULE 3
Alex Sheppard
DESIGN
INTRODUCTION
Petrol stations usually show prices and amount of petrol dispensed on each petrol pump and also have a console in the office showing information about each sale from each petrol pump on the garage forecourt.
The pump shows how much petrol has been sold, the price per litre in pence to one decimal place and the total amount to pay. The console also displays this information for each pump.
Peter owns a petrol station with one petrol pump. Every day he needs to know the number of litres of petrol that are sold and the total amount of money taken for the pump.
A program is required to simulate the display on the pump and on the console for the 1 pump.
DATA REQUIREMENTS
Variable Name
Data Type
Description
Example
Validation
LitresDispensed
Single
Stores the number of litres the customer has put in their vehicle
45.6
Range
Format
PerLitre
Single
Stores the price per litre
09.9
Format
Presence
AmountToPay
Single
Stores the amount the customer has to pay
76.54
-
TotalPetrol
Single
Stores the amount of petrol sold in the day
567.8
-
TotalTakings
Single
Stores the amount of money taken in the day
£501.23
-
NoOfCustomers
Single
Stores the number of customers that have used the pump in the day
1
-
Password
String
Stores the password required to unlock the console
password123
Presence
USER INTERFACE
MAIN FORM
This form will be shown first when the program is run. It will be split in 2, with the pump on 1 side and the console on the other side. For security reasons, the console will not be shown without a password being entered to unlock it. Most of the functions will be carried out from this form, such as filling the car with petrol and Peter using the console functions.
LOGIN FORM
When the user wishes to access the console, this dialog will be shown and allow the user to enter a password, that will unlock the console if the password entered is correct. When main form is loaded, the console will be hidden.
NEW PRICE PER LITRE
This dialog will be shown when the user wishes to change the price per litre. It will allow the user to enter the new price in pence, which will then put onto the pump LCD and onto the console display.
STRUCTURE CHART
PSEUDOCODE ALGORITHMS
PUMP OPERATION
Event: Clicking Remove / Replace Nozzle Button
If Button says Remove then
Button says Replace
On Console Zero Dispensed Button is enabled
If Button says Replace then
Button says Remove
Button Squeeze is disabled
On Console Pump is marked out of use
Petrol Dispensed, Price and Number of Customers increase accordingly
End If
Event: Clicking Squeeze / Stop Squeezing Nozzle Button
If Button Says Squeeze then
Button says Stop Squeezing
Button Nozzle is disabled
Timer is enabled
On Console State of Pump = In Use
If Button says Stop Squeezing then
Button says Squeeze
Button Nozzle is enabled
Timer is disabled
End If
CONSOLE OPERATION
Event: Clicking Zero Petrol Dispensed Button
On Pump, Number of Litres ...
This is a preview of the whole essay
On Console Pump is marked out of use
Petrol Dispensed, Price and Number of Customers increase accordingly
End If
Event: Clicking Squeeze / Stop Squeezing Nozzle Button
If Button Says Squeeze then
Button says Stop Squeezing
Button Nozzle is disabled
Timer is enabled
On Console State of Pump = In Use
If Button says Stop Squeezing then
Button says Squeeze
Button Nozzle is enabled
Timer is disabled
End If
CONSOLE OPERATION
Event: Clicking Zero Petrol Dispensed Button
On Pump, Number of Litres and Amount to Pay are set to 0
On Console, Number of Litres and Amount to Pay are set to 0
Pump = Ready for Use
On Pump, Squeeze Nozzle Button is enabled
Event: Clicking New Price per Litre Button
Dialog appears where the user enters the new price
On OK Button clicked then
Price per litre set to entered price
PerLitre variable set to price entered
Event: Click New Day Button
Message box appears awaiting confirmation
If Yes is clicked then
On Pump, number of litres and amount to pay set to 0
On Console, number of litres and amount to pay set to 0
On Console, NoOfCustomers, TotalPetrol and TotalTakings variables set to 0
Message box appears confirming the actions have taken place
Else: Do nothing
End If
SIMULATING THE SEVEN SEGMENT LCD DISPLAY
Event: Timer Tick while the pump is being squeezed
Litres dispensed variable + 0.1
On Console number of litres dispensed = variable
Amount to pay = number of litres × price per litre
On Console the amount to pay = variable
With the Number of Litre
Loop from the 1st digit to the last
Take the digit and change the LCD digit to this digit
With the Amount to pay
Loop from the 1st digit to the last
Take the digit and change the LCD digit to this digit
If number of litres ? 99.9 then
Timer is disabled
Squeeze button is disabled
Message box telling user tank is full
End If
Event: New Price per Litre changed
With the Price per Litre
Loop from the 1st digit to the last
Take the digit and change the LCD digit to this digit
PRODUCTION OF DAILY TOTALS
Event: Calculating daily totals when pump is replaced
On Replace Nozzle Button clicked then
Number of litres dispensed added to TotalPetrol variable
Amount to pay added to TotalPetrol variable
Number of customer's variable increases by 1
SECURITY
To ensure that the system is secure, when the program is run, the console will remain hidden. A button will allow the user to enter the password in a dialog window. If the credentials are entered incorrectly a message box will appear saying this and allow the user to enter them again. If they are correct the button disappears and the console is displayed.
IMPLEMENTATION
USER INTERFACE
MAIN FORM- CONSOLE HIDDEN
When the program is started, the homepage is shown. This allows the customer to use the pump and Peter to use the console. They appear on the same form that has been split in 2. The pump is automatically shown and the console is hidden.
MAIN FORM- CONSOLE UNLOCKED
The console cannot be used without clicking the Activate Console button and entering the password to make the console visible. Then Peter can use the controls on the console that perform administrative tasks, such as changing the price per litre and viewing the daily totals.
LOGIN DIALOG
The login dialog is a simple form where the password to show the console can be entered. The characters entered are hidden with the '*' symbol for security. When OK is pressed, the entered password is compared with the correct password and if they are the same the console is unlocked. Otherwise the console remains hidden.
PRICE PER LITRE DIALOG
This form has a similar layout to the login dialog. It allows Peter to enter a new price per litre in the format shown and when OK is pressed
LITRES SOLD
From the console, Peter can see the number of litres sold during the last day, in the form of a message box.
TOTAL TAKINGS
From the console, Peter can see the amount of money taken during the last day, in the form of a message box.
NEW DAY
On the console, Peter has the option to start a new day, which will have a confirmation dialog. If he confirms, then the totals will be reset to 0 and the number of customers.
TESTING
TEST DATA
Test Purpose
Test Data
Expected Results
Observed Results/ Changes
New price per litre (typical)
Price per litre: 123.4
LCD on the pump and the display on the console to change to the price entered
As expected (SS1)
New price per litre (boundary)
Price per litre: 199.9
LCD on the pump and the display on the console to change to the price entered
As expected (SS2)
New price per litre (boundary)
Price per litre: 0.1
LCD on the pump and the display on the console to change to the price entered
As expected (SS3)
New price per litre (erroneous)
Price per litre: 299.9
Message box to appear telling the user to enter a price less than 199.9 p.
As expected (SS4)
New price per litre (erroneous)
Price per litre: test
Message box to appear telling the user to enter a price in the correct format.
As expected (SS5)
Starting a new day
Confirmation: Yes
Message box to close, with the total petrol dispensed, total takings and number of customers to reset to 0. The amount of litres sold and the amount to pay from the last pump use is cleared.
As expected (SS6)
Starting a new day
Confirmation: No
Message box to close and leave the daily totals as they were
As expected (SS7)
Pump and Console displays match
Number of litres: 4.9
Price per litre: 89.9
Amount to pay: £4.41
When the pump is replaced, the number of litres and amount to pay should be the same on the pump LCD and on the console.
Litres Dispensed × Price per litre = Cost
4.9 × 089.9 = £4.41
As expected (SS8)
Resetting the pump
When the Zero Petrol Dispensed button is pressed, the number of litres and amount to pay will be reset to 0 and the customer can start squeezing the nozzle. The Pump is set Ready for Use.
As expected (SS9)
Correct working of console display
Number of litres: 1.7
Price per litre: 89.9
The number of litres should go up in 0.1 of a litre.
The amount to pay is the number of litres multiplied by the price per litre.
Litres Dispensed × Price per litre = Cost
.7 × 089.9 = £1.53
.8 × 089.9 = £1.62
As expected (SS10)
The pump LCD's display the correct numbers
Price per litre 1: 012.3
Price per litre 2: 045.6
Price per litre 3: 078.9
When the price per litre is changed, the price per litre on the console should also change.
All numbers 0-9 will be used in the price per litre.
As expected (SS11)
A day's operation with 7 customers
(see test data table at beginning of Testing section with the 7 customers)
The number of litres and amount to pay for each customer should be added to the totals and the number of customers should increase by 1.
When the Total Petrol button is pressed, a message box should appear with the total number of litres sold (317.4).
When the Total Takings button is pressed, a message box should appear with the amount of money taken (£355.74).
As expected (SS12)
The pump displays price per litre to 1 decimal place, litres dispensed to 1 decimal place and amount to pay in pounds and pence.
The console displays price per litre to 1 decimal place, litres dispensed to 1 decimal place and amount to pay in pounds and pence.
Number of litres: 3.1
Price per litre: 89.9
Amount to pay: £2.79
The pump will display price per litre to 1 decimal place, litres dispensed to 1 decimal place and amount to pay in pounds and pence.
The console will display price per litre to 1 decimal place, litres dispensed to 1 decimal place and amount to pay in pounds and pence.
As expected (SS13)
The console displays the state of the pump
When the customer arrives, the pump will be out of use.
When Peter zeros the pump it will be ready for use.
When the customer squeezes the pump it is in use.
As expected (SS14)
The pump dispenses between 0.5 - 99.9 litres (typical)
Number of litres: 4.9
When the customer stops squeezing, the nozzle can be replaced.
As expected (SS15)
The pump dispenses between 0.5 - 99.9 litres (boundary)
Number of litres: 0.6
When the customer stops squeezing, the nozzle can be replaced.
As expected (SS16)
The pump dispenses between 0.5 - 99.9 litres (boundary)
Number of litres: 99.9
When the customer stops squeezing, the nozzle can be replaced.
As expected (SS17)
The pump dispenses between 0.5 - 99.9 litres (erroneous)
Number of litres: 0.3
When the customer stops squeezing and replaces the pump, an error message will be displayed saying too little petrol has been dispensed.
As expected (SS18)
The pump dispenses between 0.5 - 99.9 litres (erroneous)
Number of litres: another timer tick after 99.9
When the number of litres dispensed reaches 99.9 a message will be displayed saying the tank is full. The customer won't be able to continue squeezing.
As expected (SS19)
Calculations of daily totals
Number of litres: 14.1
Price per litre: 89.9
After the customer replaces the nozzle, the number of litres dispensed and amount to pay should be added to the totals. The number of customers should increase by 1.
Litres Dispensed × Price per litre = Cost
4.1 × 089.9 = £12.68
As expected (SS20)
TESTING SCREENSHOTS
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
20
CODE
Alex Sheppard - 1 - Computing AS
Alex Sheppard - 32 - Computing AS