Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- /* Обработать исключения
- * Сделать нормальную сортировку по алфавиту
- */
- namespace Lab2_mod3
- {
- class Class1
- {
- const int LENGTH_ARR = 4;
- static private ORDER[] operations = new ORDER[LENGTH_ARR];
- struct ORDER
- {
- private string payerCurrentAcc;
- private string recipientCurrentAcc;
- private decimal sumRUB;
- public string PayerCurrentAcc
- {
- get { return payerCurrentAcc; }
- set
- {
- if (value.Length > 0) payerCurrentAcc = value;
- else
- {
- Console.WriteLine("Ошибка! Вы не указали расчетный счет плательщика");
- Menu();
- }
- }
- }
- public string RecipientCurrentAcc
- {
- get { return recipientCurrentAcc; }
- set
- {
- if ("" != value) recipientCurrentAcc = value;
- else
- {
- Console.WriteLine("Ошибка! Вы не указали расчетный счет получателя");
- Menu();
- }
- }
- }
- public decimal SumRUB
- {
- get { return sumRUB; }
- set
- {
- if (0 != value) sumRUB = value;
- else
- {
- Console.WriteLine("Ошибка! Вы не указали перечисляемую сумму");
- Menu();
- }
- }
- }
- public ORDER(string payerCurrentAcc_, string recipientCurrentAcc_, decimal sumRUB_)
- {
- payerCurrentAcc = payerCurrentAcc_;
- recipientCurrentAcc = recipientCurrentAcc_;
- sumRUB = sumRUB_;
- }
- }
- static void Main()
- {
- if(checkAccount("12AB")) Console.WriteLine("true1");
- if(checkAccount("azz")) Console.WriteLine("true2");
- Console.WriteLine("-------------------------------------------------");
- Console.WriteLine("--------------------Lab2_mod3--------------------");
- Console.WriteLine("-------------------------------------------------");
- Console.WriteLine();
- Console.WriteLine("Введите данные платежей");
- string read;
- ORDER temp;
- decimal temp2;
- int k = 0;
- Console.WriteLine("------- Операция {0} ------", 1);
- Console.Write("Введите расчетный счет плательщика: ");
- operations[0].PayerCurrentAcc = Console.ReadLine();
- Console.Write("Введите расчетный счет получателя: ");
- operations[0].RecipientCurrentAcc = Console.ReadLine();
- Console.Write("Введите сумму операции в рублях: ");
- if (decimal.TryParse(Console.ReadLine(), out temp2))
- {
- operations[0].SumRUB = temp2;
- }
- else { Console.WriteLine("Ошибка преобразования!"); }
- for (int i = 1; i < LENGTH_ARR; i++)
- {
- Console.WriteLine("------- Операция {0} ------", i+1);
- Console.Write("Введите расчетный счет плательщика: ");
- read = Console.ReadLine();
- operations[i].PayerCurrentAcc = read;
- Console.Write("Введите расчетный счет получателя: ");
- operations[i].RecipientCurrentAcc = Console.ReadLine();
- Console.Write("Введите сумму операции в рублях: ");
- if (decimal.TryParse(Console.ReadLine(), out temp2))
- {
- operations[i].SumRUB = temp2;
- }
- else { Console.WriteLine("Ошибка преобразования!"); }
- k = i;
- while ( k > 0 && operations[k].PayerCurrentAcc[0] < operations[k-1].PayerCurrentAcc[0] )
- {
- temp = operations[k - 1];
- operations[k - 1] = operations[k];
- operations[k] = temp;
- k--;
- }
- }
- Menu();
- Console.ReadKey();
- }
- static void Menu()
- {
- try
- {
- Console.WriteLine("-------------------------------------------------");
- Console.WriteLine("----------------------Menu-----------------------");
- Console.WriteLine("-------------------------------------------------");
- Console.WriteLine("1.Получить сумму, снятую с рассчетного счета плательщика");
- Console.WriteLine("2.Вывести информацию по всем платежам");
- Console.WriteLine("3.Выход");
- switch (Convert.ToInt32(Console.ReadLine()))
- {
- case 1:
- string account;
- decimal sum = 0;
- Console.Write("Введите расчетный счет: ");
- account = Console.ReadLine();
- for (int i = 0; i < LENGTH_ARR; i++)
- {
- if (account == operations[i].PayerCurrentAcc) sum += operations[i].SumRUB;
- }
- if (0 != sum) Console.WriteLine("С этого счета было снято: {0}", sum);
- else Console.WriteLine("С этого счета деньги не снимались!");
- Menu();
- break;
- case 2:
- for (int i = 0; i < LENGTH_ARR; i++)
- {
- Console.WriteLine("------- Операция {0} ------", i + 1);
- Console.WriteLine("Расчетный счет плательщика: {0}", operations[i].PayerCurrentAcc);
- Console.WriteLine("Расчетный счет получателя: {0}", operations[i].RecipientCurrentAcc);
- Console.WriteLine("Сумма операции в рублях: {0}", operations[i].SumRUB);
- }
- Menu();
- break;
- case 3:
- Environment.Exit(0);
- break;
- default:
- Console.WriteLine("Ошибка ввода, повторите попытку!");
- Menu();
- break;
- }
- }
- catch
- {
- }
- }
- static bool checkAccount(string str)
- {
- bool status = false;
- status = Regex.IsMatch(str, @"\b[a-z]");
- return status;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement