Skip to content

Instantly share code, notes, and snippets.

@MichaelDimitras
Created May 21, 2018 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelDimitras/2d7eb30870a4519d7531ea9649d75065 to your computer and use it in GitHub Desktop.
Save MichaelDimitras/2d7eb30870a4519d7531ea9649d75065 to your computer and use it in GitHub Desktop.
class Cashier {
constructor(//string priceList, float startingMoney, float salesTax){
//parse the csv priceList and store it as a nested json, where for each product key = sku, value =a json object of the products other properties
//Store the other parameters in respective properties
//Initialize a boolean inTransaction property to false.
//Initialize a transactions object where the key is transaction id, and values
//are a csv string of transacition details
}
function viewBalance() {
//if the register is not currently involved in a transaction, return the amount of money currently in the register
}
function startTransaction(//object customer) {
//set inTransaction to true
//instantiate a new transaction with a unique id, and the customer passed in as a parameter
//set the customer's 'currentTransaction' property to the transaction object
}
function scanItem(//string sku, object transaction) {
//add the product corresponding to the sku to the transaction's 'products' array
//incriment the transaction's 'total' propery by the product's price
}
function closeTransaction(//float cashTendered, object transaction) {
//set inTransaction to false
//determine the amount of change to give to the customer
//add the transaction to the 'transactions' object
//set the customer's 'currentTransaction' property to null
//display to the customer a list of products purchased and their grand totas
}
funcation viewTransactions() {
//iterate over the Cashier's 'transactions' object, displaying imformation for each transaction
}
funcation searchProducts() {
//search the Cashier's 'transaction's object for specific products
}
}
class Customer {
constructor() {
//initialize a currentTransaction property to null
}
function seeCurrentTotal() {
//returns the 'total' property of the customer's 'currentTransaction' if there is one
}
function seeLastScannes() {
//returns th last element of the 'products' array of the customer's 'currentTransaction' if there is one
}
function findChange(//float cashAmount) {
//return how much change the customer will recieve if they pay cashAmount for their 'currentTransaction'
}
}
class Transaction {
constructor(//int id, object customer) {
//set the transaction's id and customer properties to the passes in parameters
//initialize a timestamp property to the current date/time
//initialize an empty array 'products' to track the products in the transaction
//initialize a 'total' property to 0 that tracks the cash amount of this transaction
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment