public String ParserTimeFromTxt(string txt) { txt = txt.Trim(); LicensePlateParser lp = new LicensePlateParser(); MinuteParser mp = new MinuteParser(); string parserLicensePlate = lp.ParseLicensePlate(txt); string parserMinutes = mp.ParseCantMinutes(txt); string starTime = ""; string[] msgList = txt.Split(' '); if (txt.Contains(':')) { if (msgList.Length == 3) { starTime = msgList[2]; } else if (msgList.Length == 4) { starTime = msgList[3]; } } else if (lp.ValidateLicensePlate(parserLicensePlate) && mp.ValidateMinutesMultiple30(mp.ValidateDigit(parserMinutes))) { starTime = DateTime.Now.ToString("HH:mm"); } return(starTime); }
public Purchase(string msg, Account myA) { DateParser dateParser = new DateParser(); string startTime = dateParser.GetTimeFromTxt(msg); MinuteParser minuteParser = new MinuteParser(); LicensePlateParser myParserLicense = new LicensePlateParser(); string licensePlate = myParserLicense.GetLicensePlate(msg); string finishTime = AddMinHour(minuteParser.GetCantMinutes(msg), startTime); myAccount = myA; MyLicensePlate = licensePlate; MyDay = MyDay; MyInitHour = startTime; MyFinHour = finishTime; }
public void BuyParking(String num, String msg) { Account myAccount = FindAccount(num); if (IsAccountEmpty(myAccount)) { throw new NotAccountException(); } else { Purchase newPurchase = new Purchase(msg, myAccount); MinuteParser minuteParser = new MinuteParser(); int cantMinutes = minuteParser.CalculateCantMinutesFromPurchase(newPurchase.MyInitHour, newPurchase.MyFinHour); int amountToDiscont = valueOfMinute.TotalPrice(cantMinutes); myAccount.DiscountBalance(amountToDiscont); RegisterPurchase(newPurchase); } }