The Stop Dispensing button will stop the petrol pump timer, this will make the dispensed petrol clock (variable – fuelClock) stop, it will also stop the pay display (variable – totalToPay) to stop calculating, and provide the final amount of petrol that the customer has to pay for the current transaction, this is calculated according to the price per litre (variable – pricePerLitre) and the dispensed petrol clock (variable – fuelClock). The button will also change the current pump status of “Pump Is In Use” to “Pump Stopped, Replace Nozzle”.
The Replace Nozzle button will change the current status of the pump from “Pump Stopped, Replace Nozzle” to “Awaiting Payment”, this will allow the cashier to await actual payment for the current transaction so that they are able to press the Reset button on their interface.
User Interface (Continued)
The Reset Pump button will change the current status of the pump from “Awaiting Payment” to “Pump Is Ready To Use”, the petrol pump will also reset the fuel timer / dispensed total (variable – fuelClock), the to pay total (variable – totalToPay), the pump will add the pay total for the current transaction to the total takings for the day (variable – totalTakings), and the pump will add the dispensed total for the current transaction to the dispensed total today display (variable – dispensedTotal). A message will also appear in the message box, on the cashiers interface identifying that the petrol pump has been reset (message – “The Pump Has Been Reset”).
The Show Daily Report button will change the message box status showing the total takings for the day (variable – totalTakings) and the dispensed total today (variable – dispensedTotal). After each transaction the ‘Total To Pay’ is added to the ‘Total Daily Takings’ variable (calculation - totalToPay + totalTakings).
The Set Price input box and button in conjunction will update the price of the petrol per litre (variable – pricePerLitre), the user will have to input the new price, and then click the Set Price button to change the price, once the price has been changed the status of the ’Message Box’ will change to “Price Has Been Adjusted”. If the new price entered is below 0.01 and above 2.00 an error message will display, such as “Price Is Too High, Must Be Below £5.00”. The price per litre displays on the customer and cashier interfaces will change immediately after the price has been adjusted.
Button Identifiers
Data Flow Diagram
How the 7 Segment LCD Works
The 7 segment LCD works in a specific way according to the attributes of Adobe Action Script 3. Each LCD digit is a movie file, with 10 frames. Each frame contains a representation of each digit.
I am able to independently set which frame each movie frame / digit to be shown at one given time. I then created a function that would accept a number type as a parameter. This function then converted the parameter into a ‘String’ and then analysed each character to individually set each digit.
Then I am able to call this digit whenever I need to update a collection of digits. Below explains, using screen dumps, on how the movie frames have been developed through 7 line segments. I made a series of if statements which made sure that the different unit, tenths, and hundredths were presented correctly at each 7 line segment digit.
Each Frame in Each Movie File
I did this for each digit on every display on the customer’s interface.
Evidence and Explanations
- Begin Fuelling (Lift Nozzle & Start Dispensing Button)
A button has been created and called ‘startDispensing_btn’, once this button is clicked; an event listener allows the action of startDispensingClick to function, the event listener used is shown below.
startDispensing_btn.addEventListener(MouseEvent.CLICK,startDispensingClick);
This will start the startDispensingClick function, this has been developed to start the fuelClock, if the pumpStatus is "Pump Is Ready To Use", the status will change to "Pump Is In Use". The seven segment LCD display will change, this is found in the startDispensingClick function, and will change the digits at the ‘To Pay (£)’ and ‘Dispensed Petrol’ according to the changePriceDisplay and the changeDigits function.
-
Stop Fuelling (Stop Dispensing Button)
A button has been cretae and called ‘stopDispensing_btn’, once the button is clicked; an event listener allows the action of stopDispensingClick to function, the event listener used is shown below.
stopDispensing_btn.addEventListener(MouseEvent.CLICK,stopDispensingClick);
This will stop the stopDispensingClick function, this has been developed to stop the fuelClock, if the pumpStatus is "Pump Is In Use", the pumpStatus will remain the same. The seven segment LCD display will stop. This will stop the digits at the ‘To Pay (£)’ and ‘Dispensed Petrol’ according to the changePriceDisplay and the changeDigits function. The startDispensing and stopDispensing button will be disabled, if press the pumpStatus will change from “Pump Is In Use” to “Pump Stopped, Replace Nozzle”. The only button that will work with the pumpStatus “Pump Stopped, Replace Nozzle” will be the replaceNozzle_btn button on the customers interface.
Evidence and Explanations (Continued)
-
Replace Nozzle (Replace Nozzle Button)
A button has been created and called ‘replaceNozzle_btn’, once the button is clicked; an event listener allows the action of replaceNozzleClick to function, the even listener is shown below.
replaceNozzle_btn.addEventListener(MouseEvent.CLICK,replaceNozzleClick);
If the pumpStatus is “Pump Stopped, Replace Nozzle”, the pumpStatus will change to “Awaiting Payment”. From this stage of the pump operation, the only button that will work is the reset_btn on the cashier’s console.
-
Reset (Reset Button)
A button has been created and called ‘reset_btn’, once the button is clicked; an event listener allows the action of resetClick to function, the even listener is shown below.
reset_btn.addEventListener(MouseEvent.CLICK,resetClick);
If the pumpStatus is “Awaiting Payment”, the pumpStatus will change to “The Pump Has Been Reset”. At this stage the amountOfFuel and totalToPay variables are reset to 0 (its default), the totalToPay is added to the totalCashTakings variable, the amountOfFuel variable is added to the dispensedTotal variable, this makes sure that the daily reports and the Dispensed Total Today display is constantly updated after every transaction.
-
Daily Report (Show Daily Report Button)
This button does not rely on any status change at all, it however displays the daily reports, therefore it displays the Dispensed Total Today figures (variable - dispensedTotal) and the Total Takings (variable – totalCashTakings).This information is shown on the cashier’s interface, within the ‘Message Box’.
Evidence and Explanations (Continued)
- Set Price (Set Price Inpact / Output Button)
An input text box and button has been created to allow a price to be set, by the user typing in the price manually. The input text box is called a ‘setPrice_txt.text’, and the button being called ‘setPrice_btn’. I have imbedded set procedure within the ‘setPriceClick’ event listener that the cashier must enter a price in between £0.01 to £1.99. If the user enters a price below £0.01, a message appears in the cashier’s message box saying “Price Is Too Low, Must Be In Between £0.01 and £1.99”, if the user enters a price that is above £1.99, a message appears in the cashier’s box saying “Price Is Too High, Must Be In Between £0.01 and £1.99”. If a suitable price is entered correctly, a message will appear at the cashier’s message box saying “Price Has Been Adjusted”, with Pence Per Litre displays being updated both on the customers (pricePerLitre), and cashiers interfaces (pricePerLitreUpdate2). Below shows three examples if the price is either enter too low, too high, or has been entered correctly.
1. Cashier display when price entered was too small
2. Cashier display when price entered was too high
3. Cashier display when price entered was correct
Implementing / Testing
Test Plan
In this section I will discuss how I tested the program, in regards to:
- Test 1: Resetting the pump
- Test 2: Begin and stop fuelling
- Test 3: Set above 199.9
- Test 4: Set the price below 010.0
- Test 5: Ensuring that the console display is working correctly
- Test 6: Testing the seven segment LCD digits
- Test 7: Complete test scenarios with eight customers
I will set the mentioned test and a set of other tests in a table below. In the table I will present a test ID, the test, the expected outcome, actual output, and the resolved / pass
Test Plan (Test 7) Completing Customer Test Scenario’s
Pump In Operation (Screenshots)
I will now show the pump in full operation, I will use screenshots and appropriate annotation with all of the screenshots.
Variable Changes
Pump In Operation (Screenshots) (Continued)
Variable Changes
Pump In Operation (Screenshots) (Continued)
Variable Changes
Pump In Operation (Screenshots) (Continued)
Variables Changes
The Code
/*++++++++++++++++++++++++++++++++++++++++++++++ TIMER START ++++++++++++++++++++++++++++++++++++++++++++++++++++*/
//This variable will shown the amount of fuel dispensed in the current transaction
var amountOfFuel:Number=0; //This variable will be set to 0
//This timer will show the pumping of fuel constantly
var fuelClock:Timer = new Timer(30); //This parameter set on the constructor is the interval between the timer
//This variable will store the amount to7 be paid
var totalToPay:Number = 0;
// This variable will store the price per litre of fuel in customers interface
var pricePerLitre:Number = 0.00; // this variable will start at 0.90
// The varuable will store the price per litre of fuel in cashiers interface
var pricePerLitreUpdate2:Number = 0.00; // this variable will start at 0.90
// The variable below will display the current state of the pump. This will help me to make sure that the pump is used at specific times
var pumpStatus:String = "Pump Is Ready To Use"
// The variable below will display cashier messages, this will alert the cashier of any changes
var messageBox:String = " "
// The variable below will display the total takings of the pump. This will constantly add each transactions total to the total takings for that session (day)
var totalCashTakings:Number=0 //this variable will start at 0
// The variable below will display the current state of the pump. This will help me to make sure that the pump is used at specific times
var cashierStatus:String = "Pump is Ready to Use"
// The variable below will display the current amount of petrol dispensed for that current transaction on customer interface
var displayPetrol:Number=0 // This variable will start at 0
// The variable below will display the current amount of petrol dispensed for that current transaction on cashier interface
var displayPetrol2:Number=0 // This variable will start at 0
//The variable below will display the total amount of petrol dispensed throughout the day
var dispensedTotal:Number=0 // This variable will start at 0
// This is an event listener, this calls functions when my timer goes off
fuelClock.addEventListener(TimerEvent.TIMER, fuelTimerHit);
//fuel TimerHit will be passed
//The next fuction will keep the pump clocking over when it's being used
function fuelTimerHit (event:TimerEvent)
{
//The line below will calculate the cost of fuel to pay
totalToPay = (amountOfFuel * (pricePerLitre /100));
// The line below calculates the dispensed total overall
dispensedTotal = (displayPetrol + dispensedTotal);
//The lines below will display the petrol dispensed on the console, constantly adding 0.01 when the timer increments
amountOfFuel +=0.01;
changePriceDisplay(totalToPay)
changeDigits(Digit1, Digit2, Digit3, Digit4, totalToPay)
changeDigits(Digit5, Digit6, Digit7, Digit8, amountOfFuel)
//displayPetrol_txt.text = amountOfFuel.toFixed(2);
displayPetrol2_txt.text = amountOfFuel.toFixed(2);
//The line below will generate the cost to pay
changeDigits(Digit1, Digit2, Digit3, Digit4, totalToPay)
// The line below will generate the cost for customers to pay on the cashiers interface
custToPay2_txt.text = totalToPay.toFixed(2);
// The code below will make sure that the
if (amountOfFuel >= 99.9)
{
fuelClock.stop()
pumpStatus = "Pump Stopped, Replace Nozzle"
updateStatus()
}
updateStatus()
// This will add the total of 0.01 to the amount of fuel
//The following piece of code will edit the field etitled displayPetrol to show the amount of fuel being dispensed
}
/*++++++++++++++++++++++++++++++++++++++++++++++ TIMER END ++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
/*++++++++++++++++++++++++++++++++++++++++++++++ LISTENERS START ++++++++++++++++++++++++++++++++++++++++++++++++*/
//I will add event listeners to my buttons here
replaceNozzle_btn.addEventListener(MouseEvent.CLICK,replaceNozzleClick);
startDispensing_btn.addEventListener(MouseEvent.CLICK,startDispensingClick);
stopDispensing_btn.addEventListener(MouseEvent.CLICK,stopDispensingClick);
reset_btn.addEventListener(MouseEvent.CLICK,resetClick);
setPrice_btn.addEventListener(MouseEvent.CLICK,setPriceClick);
showDailyReport_btn.addEventListener(MouseEvent.CLICK,showDailyReportClick);
/*++++++++++++++++++++++++++++++++++++++++++++++ LISTENERS FINISH +++++++++++++++++++++++++++++++++++++++++++++++*/
/*++++++++++++++++++++++++++++++++++++++++++++++ EVENT HANDLERS START +++++++++++++++++++++++++++++++++++++++++++*/
//I will now add my event handlers on my buttons here
function startDispensingClick(event:MouseEvent):void
{
if (pumpStatus == "Pump Is Ready To Use") // This IF statement will compare the status of pumpStatus with the string "Pump is Ready to Use"
{
fuelClock.start(); // This will start the 'fuelClock' and the next line will change the pump's status
pumpStatus = "Pump Is In Use" // This is an alternative statement to if (else), this indicates if the "Pump Is In Use" by the customer
}
// This will changed the digits 5,6,7,8 (the digits that operate the "Dispensed Petrol" LCD display
changeDigits(Digit5, Digit6, Digit7, Digit8, 0.00)
updateStatus()
changePenceDisplay(pricePerLitre)
}
function replaceNozzleClick(event:MouseEvent):void
{
if (pumpStatus == "Pump Stopped, Replace Nozzle") // If the Replace Nozzle button is clicked, and the status is currently "Pump Stopped, Replace Nozzle", the status will change to "Awaiting Payment"
{
pumpStatus = "Awaiting Payment"
}
updateStatus()
}
function resetClick(event:MouseEvent):void
{
if(totalToPay == 0 && amountOfFuel == 0) // if the reset pump button is clicked
{
//twice in a row all values are set to zero
totalCashTakings = 0
dispensedTotal = 0
dispensedTotal_txt.text = dispensedTotal.toFixed(2)
updateStatus()
changePriceDisplay(0.00)// sets the price display to 0.00
}
if (pumpStatus == "Awaiting Payment") // If the current pump status is "Awaiting Payment", the message box will appear with a new message, the total to pay will add onto totalCashTakings, and the amountOfFuel will add to dispensedTotal, these will also reset back to 0
{
messageBox = "The Pump Has Been Reset"
totalCashTakings += totalToPay;
dispensedTotal += amountOfFuel;
amountOfFuel = 0;
totalToPay = 0;
//displayPetrol_txt.text = amountOfFuel.toFixed(2);
displayPetrol2_txt.text = amountOfFuel.toFixed(2);
//custToPay_txt.text = totalToPay.toFixed(2);
custToPay2_txt.text = totalToPay.toFixed(2);
pumpStatus = "Pump Is Ready To Use" // This status will be actioned if the reset button is pushed
dispensedTotal_txt.text = dispensedTotal.toFixed(2); // This will display the Total Dispensed display on the cashier interface
changePriceDisplay(0.00)//sets the price display to 0.00
updateStatus()
}
else if (amountOfFuel == 0)
{
dispensedTotal = 0;
totalCashTakings = 0;
updateStatus()
}
}
function stopDispensingClick(event:MouseEvent):void
{
if (pumpStatus == "Pump Is In Use") // this IF statement will compare the status of pumpStatus with the string "Please Replace Nozzle"
{
fuelClock.stop(); // This will stop the 'fuelClock' and the next line will change the pump's status
pumpStatus = "Pump Stopped, Replace Nozzle"
}
else if (pumpStatus == "Please Stop Dispensing") // this IF statement will compare the status of pumpStatus with the string "Please Stop Dispensing"
{
fuelClock.stop(); // This will stop the 'fuelClock' and the next line will change the pump's status
pumpStatus = "Please Replace Nozzle"
}
else if (pumpStatus == "Pump Stopped Dispensing")
{
pumpStatus = "Please Replace Nozzle"
fuelClock.stop(); // This will stop the 'fuelClock' and the next line will change the pump's status
}
else
{
messageBox = "Pump Is Ready To Use"
}
}
updateStatus()
//Below shows an event handler that will show the status of the pump, when several buttons are clicked
function updateStatus() // This function will change the status when different events happen
{
statusBox_txt.text = pumpStatus // This will change the pumpStatus in the statusBox
cashierStatus_txt.text = pumpStatus // This will change the pumpStatus in the CashierStatus
messageBox_txt.text = messageBox // This will change the messageBox status whe/* changeDigits(Digit1, Digit2, Digit3, Digit4, totalToPay); //
This will change the digits on the 'To Pay' display
/*changeDigits(Digit1, Digit2, Digit3, Digit4, totalToPay); // This will change the digits on the 'To Pay' display*/
changeDigits(Digit5, Digit6, Digit7, Digit8, amountOfFuel); // This will change the digits on the 'Dispensed Petrol' display
}
function setPriceClick (event:MouseEvent)
{
if (Number(setPrice_txt.text) < 010.0) // this IF statement will compare the status of pumpStatus with the string "Please Replace Nozzle"
{
messageBox = "Price Is Too Low, Must Be In Between £0.01 and £1.99"
updateStatus()
}
else if (Number(setPrice_txt.text) > 199.9)
{
messageBox = "Price Is Too High, Must Be In Between £0.01 and £1.99"
updateStatus()
//price too high
}
else // price is within limits
{
messageBox = "Price Has Been Adjusted"
// set the pricePerLitre to number, it also prints the pricePerLitre in the text box setPrice_txt.text
pricePerLitre = Number(setPrice_txt.text)
//pricePerLitreUpdate_txt.text = setPrice_txt.text
pricePerLitreUpdate2_txt.text = setPrice_txt.text
// This changes the digits for pricePerLitre
changePenceDisplay(pricePerLitre)
updateStatus()
}
}
function showDailyReportClick (event:MouseEvent)
{
messageBox = "Total Cash Takings Today \t £" + totalCashTakings.toFixed(2) + "\nDispensed Total Today (Litres) \t" + dispensedTotal.toFixed
updateStatus()
changePriceDisplay(22.36)
}
// Below shows the fumction that changes the digits on the customer console
function changeDigits(D1_mc:MovieClip, D2_mc:MovieClip, D3_mc:MovieClip, D4_mc:MovieClip, xy:Number)
{
// Below are the variables that holds the digits in temp form, the tempSt holds the number in temp
var tempSt:String
var tempNo:Number = 0
tempSt = String(xy.toFixed(2))
if (xy >= 10)
{
tempNo = Number (tempSt.charAt(0))
D1_mc.gotoAndStop(tempNo + 1) // This is changing the first digit
tempNo = Number (tempSt.charAt(1))
D2_mc.gotoAndStop(tempNo + 1) // This is changing the second digit
tempNo = Number (tempSt.charAt(3))
D3_mc.gotoAndStop(tempNo + 1) // This is changing the third digit
tempNo = Number (tempSt.charAt(4))
D4_mc.gotoAndStop(tempNo + 1) // This is changing the forth digit
}
else
{
D1_mc.gotoAndStop(1) // This is changing the first digit
tempNo = Number (tempSt.charAt(0))
D2_mc.gotoAndStop(tempNo + 1) // This is changing the second digit
tempNo = Number (tempSt.charAt(2))
D3_mc.gotoAndStop(tempNo + 1) // This is changing the third digit
tempNo = Number (tempSt.charAt(3))
D4_mc.gotoAndStop(tempNo + 1) // This is changing the forth digit
}
}
function changePenceDisplay(xy:Number)
{
// Below are the variables that holds the digits in temp form, the tempSt holds the number in temp
var tempSt:String
var tempNo:Number = 0
tempSt = String(xy.toFixed(1))
if (xy >= 100)
{
tempNo = Number (tempSt.charAt(0))
penceD1.gotoAndStop(tempNo + 1) // This is changing the first digit
tempNo = Number (tempSt.charAt(1))
penceD2.gotoAndStop(tempNo + 1) // This is changing the second digit
tempNo = Number (tempSt.charAt(2))
penceD3.gotoAndStop(tempNo + 1) // This is changing the third digit
tempNo = Number (tempSt.charAt(4))
penceD4.gotoAndStop(tempNo + 1) // This is changing the forth digit
}
else
{
// Loads Digits 1
penceD1.gotoAndStop(1) // This is changing the first digit
// Loads Digits 2
tempNo = Number (tempSt.charAt(0))
penceD2.gotoAndStop(tempNo + 1) // This is changing the second digit
// Loads Digit 3
tempNo = Number (tempSt.charAt(1))
penceD3.gotoAndStop(tempNo + 1) // This is changing the third digit
// Loads Digit 4
tempNo = Number (tempSt.charAt(3))
penceD4.gotoAndStop(tempNo + 1) // This is changing the forth digit
}
}
function changePriceDisplay(xy:Number)
{
// Below are the variables that holds the digits in temp form, the tempSt holds the number in temp
var tempSt:String
var tempNo:Number = 0
tempSt = String(xy.toFixed(2))
if (xy >= 100)
{
// Loads Digit 1
tempNo = Number (tempSt.charAt(0))
priceD1.gotoAndStop(tempNo + 1) // This is changing the first digit
// Loads Digit 2
tempNo = Number (tempSt.charAt(1))
priceD2.gotoAndStop(tempNo + 1) // This is changing the second digit
// Loads Digit 3
tempNo = Number (tempSt.charAt(2))
priceD3.gotoAndStop(tempNo + 1) // This is changing the third digit
// Loads Digit 4
tempNo = Number (tempSt.charAt(4))
priceD4.gotoAndStop(tempNo + 1) // This is changing the forth digit
// Loads Digit 5
tempNo = Number (tempSt.charAt(5))
priceD5.gotoAndStop(tempNo + 1) // This is changing the fifth digit
}
else if (xy <100 && xy >=10)
{
// Loads Digit 1
priceD1.gotoAndStop(1) // This is changing the first digit
// Loads Digit 2
tempNo = Number (tempSt.charAt(0))
priceD2.gotoAndStop(tempNo + 1) // This is changing the second digit
// Loads Digit 3
tempNo = Number (tempSt.charAt(1))
priceD3.gotoAndStop(tempNo + 1) // This is changing the third digit
// Loads Digit 4
tempNo = Number (tempSt.charAt(3))
priceD4.gotoAndStop(tempNo + 1) // This is changing the forth digit
// Loads Digit 5
tempNo = Number (tempSt.charAt(4))
priceD5.gotoAndStop(tempNo + 1) // This is changing the fifth digit
}
else
{
// Loads Digit 1
priceD1.gotoAndStop(1) // This is changing the first digit
// Loads Digit 2
priceD2.gotoAndStop(1) // This is changing the second digit
// Loads Digit 3
tempNo = Number (tempSt.charAt(0))
priceD3.gotoAndStop(tempNo + 1) // This is changing the third digit
// Loads Digit 4
tempNo = Number (tempSt.charAt(2))
priceD4.gotoAndStop(tempNo + 1) // This is changing the forth digit
// Loads Digit 5
tempNo = Number (tempSt.charAt(3))
priceD5.gotoAndStop(tempNo + 1) // This is changing the fifth digit
}
}
/*++++++++++++++++++++++++++++++++++++++++++++++ EVENT HANDLERS STOP ++++++++++++++++++++++++++++++++++++++++++*/