Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace tane_superior
- {
- public class Item
- {
- public string Name
- {
- get;
- }
- public double Price
- {
- get;
- }
- public int Quantity
- {
- get;
- }
- public Item(string itemName, double itemPrice, int numPurchased)
- {
- Name = itemName;
- Price = itemPrice;
- Quantity = numPurchased;
- }
- public override string ToString()
- {
- return $"{Name}\t\t{Price:C}\t\t{Quantity}\t\t{Price * Quantity:C}";
- }
- }
- public class ShoppingCart
- {
- private int itemCount;
- private double totalPrice;
- private int capacity;
- private Item[] cart;
- public ShoppingCart()
- {
- capacity = 5;
- itemCount = 0;
- totalPrice = 0.0;
- cart = new Item[capacity];
- }
- public void AddToCart(string itemName, double price, int quantity)
- {
- if (itemCount + 1 <= capacity)
- {
- cart[itemCount] = new Item(itemName, price, quantity);
- totalPrice += price;
- itemCount += 1;
- }
- else
- {
- IncreaseSize();
- }
- }
- private void IncreaseSize()
- {
- capacity += 3;
- }
- public override string ToString()
- {
- string contents = "\nShopping Cart\n";
- contents += "\nItem\t\tUnit Price\tQuantity\tTotal\n";
- for (int i = 0; i < itemCount; i++)
- {
- contents += cart[i] + "\n";
- }
- contents += $"\nTotal Price: {totalPrice:C}\n";
- return contents;
- }
- }
- internal class Nigger
- {
- public static int IntReader()
- {
- bool success = (bool)default;
- int number = (int)default;
- while (!success)
- {
- if (int.TryParse(Console.ReadLine(), out number))
- {
- success = true;
- }
- else Console.WriteLine("было введено неправильное число, выполните ввод заново");
- }
- return number;
- }
- public static bool CycleBreaker()
- {
- int response = (int)default;
- bool conclusion = (bool)default;
- bool success = (bool)default;
- while (!success)
- {
- switch (response)
- {
- case 1:
- }
- }
- return conclusion;
- }
- }
- internal class Program
- {
- private static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement