Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Stores
- {
- enum Classe
- {
- ECONOM, STANDARD, PREMIUM
- }
- enum LoyaltyProgram
- {
- BASIC, SILVER, GOLDEN
- }
- class Product
- {
- public List<string> properties = new List<string>();
- public readonly string name, type;
- public readonly int tax;
- public readonly int[,] prices = new int[2, 2];
- public readonly Classe classe;
- public Product()
- {
- Console.Write("Input the product's name: ");
- name = Console.ReadLine();
- Console.Write("Input the type: ");
- type = Console.ReadLine();
- Console.Write("Input the tax (in %): ");
- tax = Convert.ToInt32(Console.ReadLine());
- Console.Write("Input the retail client price: ");
- prices[0, 0] = Convert.ToInt32(Console.ReadLine());
- Console.Write("Input the retail corporative price: ");
- prices[0, 1] = Convert.ToInt32(Console.ReadLine());
- Console.Write("Input the wholesale client price: ");
- prices[1, 0] = Convert.ToInt32(Console.ReadLine());
- Console.Write("Input the wholesale corporative price: ");
- prices[1, 1] = Convert.ToInt32(Console.ReadLine());
- bool flag = true;
- while (flag)
- {
- Console.Write("Add some properties (add - to add a property\tstop - to stop the input):\n> ");
- switch (Console.ReadLine())
- {
- case "add":
- properties.Add(Console.ReadLine());
- Console.Clear();
- break;
- case "stop":
- flag = false;
- Console.Clear();
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: there is no such action!");
- break;
- }
- }
- flag = true;
- while (flag)
- {
- Console.Write("Input the class (1. Econom\t2. Standard\t3. Premium):\n> ");
- switch (Console.ReadLine())
- {
- case "1":
- classe = Classe.ECONOM;
- flag = false;
- break;
- case "2":
- classe = Classe.STANDARD;
- flag = false;
- break;
- case "3":
- classe = Classe.PREMIUM;
- flag = false;
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: there is no such class!");
- break;
- }
- }
- }
- }
- class Stand
- {
- public List<Product> goods = new List<Product>();
- public Stand()
- {
- bool flag = true;
- while (flag)
- {
- Console.Write("Add some goods (add - to add a product\tstop - to stop the input):\n> ");
- switch (Console.ReadLine())
- {
- case "add":
- goods.Add(new Product());
- Console.Clear();
- break;
- case "stop":
- flag = false;
- Console.Clear();
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: there is no such action!");
- break;
- }
- }
- }
- }
- class Store
- {
- private string name;
- private LoyaltyProgram loyalty;
- private static List<Stand> stands = new List<Stand>();
- public Store()
- {
- Console.Write("Input the name: ");
- name = Console.ReadLine();
- bool flag = true;
- while (flag)
- {
- Console.Write("Input the loyalty program (1. Basic\t2. Silver\t3. Golden):\n> ");
- switch (Console.ReadLine())
- {
- case "1":
- loyalty = LoyaltyProgram.BASIC;
- flag = false;
- break;
- case "2":
- loyalty = LoyaltyProgram.SILVER;
- flag = false;
- break;
- case "3":
- loyalty = LoyaltyProgram.GOLDEN;
- flag = false;
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: there is no such loyalty program!");
- break;
- }
- }
- flag = true;
- while (flag)
- {
- Console.Write("Add some stands (add - to add a stand\tstop - to stop the input):\n> ");
- switch (Console.ReadLine())
- {
- case "add":
- stands.Add(new Stand());
- Console.Clear();
- break;
- case "stop":
- flag = false;
- Console.Clear();
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: there is no such action!");
- break;
- }
- }
- }
- public void ShowInfo()
- {
- int[,,] discount = new int[3, 2, 2];
- discount[0, 0, 0] = discount[2, 0, 1] = discount[1, 1, 1] = 5;
- discount[1, 0, 0] = discount[1, 1, 0] = 7;
- discount[0, 1, 0] = discount[2, 1, 1] = 6;
- discount[0, 0, 1] = 2;
- discount[0, 1, 1] = 3;
- discount[1, 0, 1] = 4;
- discount[2, 0, 0] = 10;
- discount[2, 1, 0] = 11;
- int[] loyaltyDiscount = { 5, 10, 15 }, wholesaleDiscount = { 2, 3, 5 };
- Console.WriteLine($"Store \"{name}\":");
- Console.Write("\tLoyalty program type: ");
- switch (loyalty)
- {
- case LoyaltyProgram.BASIC:
- Console.WriteLine("Basic");
- break;
- case LoyaltyProgram.SILVER:
- Console.WriteLine("Silver");
- break;
- case LoyaltyProgram.GOLDEN:
- Console.WriteLine("Golden");
- break;
- }
- for (int i = 0; i < stands.Count; i++)
- {
- Console.WriteLine($"\tStand {i + 1}:");
- for (int j = 0; j < stands[i].goods.Count; j++)
- {
- Console.WriteLine($"\t\tProduct \"{stands[i].goods[j].name}\":");
- Console.WriteLine($"\t\t\tType: \"{stands[i].goods[j].type}\"");
- Console.Write($"\t\t\tClass: ");
- switch(stands[i].goods[j].classe)
- {
- case Classe.ECONOM:
- Console.WriteLine("Econom");
- break;
- case Classe.STANDARD:
- Console.WriteLine("Standard");
- break;
- case Classe.PREMIUM:
- Console.WriteLine("Premium");
- break;
- }
- Console.WriteLine("\t\t\tProperties:");
- for (int k = 0; k < stands[i].goods[j].properties.Count; k++)
- {
- Console.WriteLine($"\t\t\t\tProperty {k + 1}: {stands[i].goods[j].properties[k]}");
- }
- Console.WriteLine("\t\t\tPrice:");
- Console.WriteLine("\t\t\t\tRetail:");
- Console.WriteLine($"\t\t\t\t\tClient: {stands[i].goods[j].prices[0, 0] * (100 + stands[i].goods[j].tax) / 100 * (100 - discount[(int)stands[i].goods[j].classe, 0, 0]) / 100 * (100 - loyaltyDiscount[(int)loyalty]) / 100}");
- Console.WriteLine($"\t\t\t\t\tCorporative: {stands[i].goods[j].prices[0, 1] * (100 + stands[i].goods[j].tax) / 100 * (100 - discount[(int)stands[i].goods[j].classe, 0, 1]) / 100 * (100 - loyaltyDiscount[(int)loyalty]) / 100}");
- Console.WriteLine("\t\t\t\tWholesale:");
- Console.WriteLine($"\t\t\t\t\tClient: ");
- for (int k = 0; k < 3; k++)
- {
- Console.WriteLine($"\t\t\t\t\t\t{Math.Pow(10, k + 1)}: {stands[i].goods[j].prices[1, 0] * (100 + stands[i].goods[j].tax) / 100 * (100 - discount[(int)stands[i].goods[j].classe, 1, 0]) / 100 * (100 - loyaltyDiscount[(int)loyalty]) / 100 * (100 - wholesaleDiscount[k]) / 100}");
- }
- Console.WriteLine($"\t\t\t\t\tCorporative: ");
- for (int k = 0; k < 3; k++)
- {
- Console.WriteLine($"\t\t\t\t\t\t{Math.Pow(10, k + 1)}: {stands[i].goods[j].prices[1, 1] * (100 + stands[i].goods[j].tax) / 100 * (100 - discount[(int)stands[i].goods[j].classe, 1, 1]) / 100 * (100 - loyaltyDiscount[(int)loyalty]) / 100 * (100 - wholesaleDiscount[k]) / 100}");
- }
- }
- }
- Console.WriteLine("Press any key to continue...");
- Console.ReadKey();
- }
- }
- class Program
- {
- private static List<Store> stores = new List<Store>();
- static void Main(string[] args)
- {
- Console.Title = "Stores";
- while (true)
- {
- CallInterface();
- switch (Console.ReadLine())
- {
- case "1":
- stores.Add(new Store());
- Console.Clear();
- break;
- case "2":
- if (stores.Count > 0)
- {
- for (int i = 0; i < stores.Count; i++)
- {
- stores[i].ShowInfo();
- }
- Console.Clear();
- }
- else
- {
- Console.Clear();
- Console.WriteLine("Error: There is no data!");
- }
- break;
- case "quit":
- Environment.Exit(0);
- break;
- default:
- Console.Clear();
- Console.WriteLine("Error: Unknown command!");
- break;
- }
- }
- }
- static void CallInterface()
- {
- string[] allActions = { "1. Add a store", "2. Show all the info" };
- void DrawBorder()
- {
- for (int i = 0; i < Console.WindowWidth; i++)
- {
- Console.Write("=");
- }
- }
- void NewLine()
- {
- Console.Write("|");
- for (int i = 0; i < Console.WindowWidth - 2; i++)
- {
- Console.Write(" ");
- }
- Console.Write("|");
- }
- void AddActions(string[] actions)
- {
- for (int i = 0; i < actions.Length; i++)
- {
- Console.Write($"| {actions[i]}");
- for (int j = 0; j < Console.WindowWidth - actions[i].Length - 3; j++)
- {
- Console.Write(" ");
- }
- Console.Write("|");
- NewLine();
- }
- }
- DrawBorder();
- NewLine();
- AddActions(allActions);
- DrawBorder();
- Console.Write("{0, 82}", "quit - exit from the interface\n> ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement