Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace Bank_Application {
- public partial class Form1 : Form {
- Queue<BankAccount> accounts = new Queue<BankAccount>();
- public Form1() {
- InitializeComponent();
- }
- class BankAccount {
- //Номер лицевого счёта
- string AccNum;
- //Размер процента вклада
- int procent;
- //Конструктор по умолчанию
- public BankAccount() {
- AccNum = "";
- procent = 0;
- }
- //Аксессор для номера счёта
- public string AccNumA {
- get {
- return AccNum;
- }
- set {
- AccNum = value;
- }
- }
- //Аксессор для процентов
- public int ProcentA {
- get {
- return procent;
- }
- set {
- procent = value;
- }
- }
- }
- private void button1_Click(object sender, EventArgs e) {
- labelAccNum.Visible = true;
- labelProcent.Visible = true;
- textBoxNumInput.Visible = true;
- textBoxProcentInput.Visible = true;
- buttonAdd.Visible = true;
- textBox1.Visible = false;
- }
- private void Form1_Load(object sender, EventArgs e) {
- accounts.Enqueue(new BankAccount() { ProcentA = 13, AccNumA = "4234623" });
- accounts.Enqueue(new BankAccount() { ProcentA = 10, AccNumA = "7862384" });
- accounts.Enqueue(new BankAccount() { ProcentA = 8, AccNumA = "5465487" });
- accounts.Enqueue(new BankAccount() { ProcentA = 14, AccNumA = "6541516" });
- accounts.Enqueue(new BankAccount() { ProcentA = 18, AccNumA = "8794657" });
- }
- private void buttonAdd_Click(object sender, EventArgs e) {
- BankAccount nev = new BankAccount();
- if (textBoxNumInput.TextLength != 0)
- nev.AccNumA = textBoxNumInput.Text;
- if (textBoxProcentInput.TextLength != 0)
- nev.ProcentA = Int32.Parse(textBoxProcentInput.Text);
- accounts.Enqueue(nev);
- }
- private void buttonPrint_Click(object sender, EventArgs e) {
- textBox1.Visible = true;
- List<string> Num = new List<string>();
- List<int> Prc = new List<int>();
- foreach (BankAccount a in accounts) {
- Num.Add(a.AccNumA);
- Prc.Add(a.ProcentA);
- }
- String[] Meta = new string[Num.Count()];
- string data;
- for (int i = 0; i<Num.Count(); i++) {
- data = $"{Num[i]}, {Convert.ToString(Prc[i])}%";
- Meta[i] = data;
- }
- textBox1.Lines = Meta;
- }
- private void buttonDelete_Click(object sender, EventArgs e) {
- buttonDeleteNum.Visible = true;
- buttonDeleteProcent.Visible = true;
- labelAccNum.Visible = false;
- labelProcent.Visible = false;
- textBoxNumInput.Visible = false;
- textBoxProcentInput.Visible = false;
- buttonAdd.Visible = false;
- buttonDelete2.Visible = true;
- textBox1.Visible = false;
- }
- private void buttonDeleteNum_Click(object sender, EventArgs e) {
- textBoxDeleteNum.Visible = true;
- textBoxDeleteProcent.Visible = false;
- label4DeleteProcent.Visible = false;
- label4DeleteNum.Visible = true;
- textBox1.Visible = false;
- }
- private void buttonDeleteProcent_Click(object sender, EventArgs e) {
- textBoxDeleteNum.Visible = false;
- textBoxDeleteProcent.Visible = true;
- label4DeleteProcent.Visible = true;
- label4DeleteNum.Visible = false;
- textBox1.Visible = false;
- }
- private void textBoxDeleteProcent_TextChanged(object sender, EventArgs e) {
- }
- private void buttonDelete2_Click(object sender, EventArgs e) {
- BankAccount delete = new BankAccount();
- BankAccount now = new BankAccount();
- if (textBoxDeleteNum.TextLength != 0) {
- delete.AccNumA = textBoxDeleteNum.Text;
- for (int i = 0; i < accounts.Count; i++) {
- now = accounts.Dequeue();
- if (now.AccNumA != delete.AccNumA) {
- accounts.Enqueue(now);
- }
- }
- }
- else {
- delete.ProcentA = Int32.Parse(textBoxDeleteProcent.Text);
- for (int i = 0; i < accounts.Count; i++) {
- now = accounts.Dequeue();
- if (now.ProcentA != delete.ProcentA) {
- accounts.Enqueue(now);
- }
- }
- }
- MessageBox.Show("Элемент успешно удалён");
- }
- private void button3_Click(object sender, EventArgs e) {
- textBoxDeleteNum.Visible = false;
- label4DeleteNum.Visible = false;
- textBox1.Visible = false;
- textBoxDeleteProcent.Visible = false;
- label4DeleteProcent.Visible = false;
- labelAccNum.Visible = false;
- labelProcent.Visible = false;
- textBoxNumInput.Visible = false;
- textBoxProcentInput.Visible = false;
- buttonAdd.Visible = false;
- buttonDeleteNum.Visible = false;
- buttonDeleteProcent.Visible = false;
- buttonDelete2.Visible = false;
- BankAccount max = new BankAccount();
- max = accounts.Peek();
- foreach (BankAccount p in accounts) {
- if (p.ProcentA > max.ProcentA) {
- max.ProcentA = p.ProcentA;
- max.AccNumA = p.AccNumA;
- }
- }
- MessageBox.Show($"Максимальный процент: {max.ProcentA} на счёте {max.AccNumA}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement