static void Main(string[] args) { //Took from assignment - was to good to create one for myself :) Stregsystem stregsystem = new Stregsystem(); StregsystemCLI cli = new StregsystemCLI(stregsystem); StregsystemCommandParser parser = new StregsystemCommandParser(stregsystem, cli); cli.Start(parser); }
public override bool Execute(Stregsystem CS) { TransactionsList transactionList = new TransactionsList(CS); UsersList usersList = new UsersList(); User.Balance = User.Balance + Amount * 100; Date = DateTime.Now; if (transactionList.AddCashTransaction(this)) { if (usersList.UpdateUser(User)) { return(true); } return(false); } return(false); }
//Algorithm for Execute, just that it filled to much - seems unreadable private bool SaveTransaction(BuyTransaction transaction, Stregsystem CS) { TransactionsList transactionList = new TransactionsList(CS); UsersList usersList = new UsersList(); User.Balance = User.Balance - Product.Price; Price = Product.Price; Date = DateTime.Now; if (transactionList.AddBuyTransaction(transaction)) { if (usersList.UpdateUser(User)) { return(true); } return(false); } return(false); }
public override bool Execute(Stregsystem CS) { double newBalance = 0.0; newBalance = User.Balance - Product.Price; if (newBalance < 0 && !Product.CanBeBoughtOnCredit) { throw new InsufficientCreditsException(); } else { if (SaveTransaction(this, CS)) { return(true); } return(false); } }
public StregsystemCLI(Stregsystem _stregsystem) { stregsystem = _stregsystem; }
//Virtual, can be changed but does not have to be public virtual bool Execute(Stregsystem CS) { return(false); }
public StregsystemCommandParser(Stregsystem _stregsystem, StregsystemCLI _cli) { stregsystem = _stregsystem; cli = _cli; }
public TransactionsList(Stregsystem _CS) { filePath = GetPath("TransactionsList.csv"); CS = _CS; }