public void ApprovePass() { Console.WriteLine(); Console.WriteLine("Are you sure you want to approve this Season Parking Pass? (y/n)"); string confirm_approve = Console.ReadLine().ToLower(); switch (confirm_approve) { case "y": vsp.SetCurrentState(vsp.GetValidState()); //set season pass state Console.WriteLine("Season pass with ID of {0} sucessfully approved.", vsp.SeasonPassID); break; case "n": Console.WriteLine(); Console.WriteLine("Action cancelled. Season Parking Pass remains pending."); break; default: Console.WriteLine(); Console.WriteLine("Invalid input. Returning to the main menu."); break; } }
public void TerminatePass() { double price; double refunded; if (vsp.VehicleType == "Car" || vsp.VehicleType == "Lorry") { price = 80; } else { price = 15; } refunded = price * vsp.RemainingMonth; Console.WriteLine("Total amount of $" + refunded + " is refunded back to you."); Console.WriteLine("Your Season Parking Pass has been terminated. Thank you and have a nice day."); //User's account will be set to terminated. vsp.SetCurrentState(vsp.GetTerminatedState()); Console.WriteLine("Season pass has been terminated."); }
public void Renew() { int price = 0; bool status = true; while (status) //if user did not confirm { Console.WriteLine("----Renew Season Parking Pass----"); Console.Write("Please enter no. of months you want to renew: "); string rpMonth = Console.ReadLine(); int rpm; bool r = Int32.TryParse(rpMonth, out rpm); if (!r) { Console.WriteLine(); Console.WriteLine("Please enter valid number"); return; } if (rpm < 0 || rpm > 15) { Console.WriteLine("Please enter a valid month between 1 -12"); return; } Console.WriteLine("Renewing season parking pass..."); Console.WriteLine("Extend season parking pass for another " + rpm + " month(s)"); string confirmation = Confirm(""); if (confirmation.ToLower() == "y") { Console.WriteLine("You decide to renew " + rpm + " month(s) of your season parking pass"); Console.WriteLine(); Console.WriteLine("Calculating season pass amount..."); if (vsp.VehicleType == "Car" || vsp.VehicleType == "Lorry") //if seasonpass is car type { price = 80; int amt = price * rpm; Console.WriteLine("Amount needed to pay: $" + amt); Console.WriteLine("Pass successfully extended for " + rpm + " month(s)"); //add payment record Payment p = new Payment(DateTime.Now, amt, "Credit", "Surface", vsp); p.makePayment(); vsp.AddPayment(p); } else if (vsp.VehicleType == "Motorbike") { //if seasonpass is motorbike type price = 15; int amt = price * rpm; Console.WriteLine("Amount needed to pay: $" + amt); Console.WriteLine("Pass successfully extended for " + rpm + " month(s)"); //add payment record Payment p = new Payment(DateTime.Now, amt, "Credit", "Surface", vsp); p.makePayment(); vsp.AddPayment(p); } //add number of months extended by user //vsp.EndDate.AddMonths(rpm); //vsp.RemainingMonth = vsp.RemainingMonth + rpm; //add input month to remaining month vsp.StartDate = DateTime.Now; vsp.EndDate = DateTime.Now.AddMonths(rpm); vsp.RemainingMonth = vsp.EndDate.Month - vsp.StartDate.Month; vsp.SetCurrentState(vsp.GetValidState()); //set season pass state to valid Console.WriteLine("The remianing month of your pass is {0} month(s)", vsp.RemainingMonth); Console.WriteLine("Your Season Pass New Expiry Date: {0}", vsp.EndDate); status = false; } } }