static void Main(string[] args) { Console.WriteLine("Enter budget"); GYM container = new GYM(Convert.ToInt32(Console.ReadLine())); Ball ball = new Ball("Pro-Universal", 30, Inventory.State.Used); Basketball basketball = new Basketball("Common-street", 8, Inventory.State.Used); Banch banch = new Banch("Level up for yourself", 79, Inventory.State.Used); Bars bars = new Bars("Some text", 60, Inventory.State.New); Ball ball1 = new Ball("asd", 2000, Inventory.State.New); container.Add(ball); container.Add(basketball); container.Add(banch); container.Add(bars); container.PrintToConsole(); Controller.SortInventory(container); Console.WriteLine("==================================================="); container.PrintToConsole(); Controller.FindFromRange(container, 2, 2); }
static void Main(string[] args) { Basketball basketball = new Basketball("Winner"); basketball.Creator = new Belarus("BelBallInc", "Minsk"); Basketball basketball1 = new Basketball("Fire"); basketball1.Creator = new Russia("RusGovCare", "Moscow"); Ball ball = new Ball("FF"); Tools tools = new Tools("pickaxe"); Inventory inventory = ball as Inventory; ball.CanMove(); ((CONFLICT_INTERFACE)ball).CanMove(); Ball ball1 = (Ball)inventory; Inventory inventory1 = ball; Inventory inventory2 = (Inventory)ball; Object obj = ball; ball1 = (Ball)obj; Console.WriteLine($"(as) ball to iventory :{ball as Inventory}"); Console.WriteLine($"(as) inventory to ball :{inventory as Ball}"); //Can't do it //Console.WriteLine($"ball to tools :{ball as Tools}"); Console.WriteLine($"(is) tools to ball :{tools is Ball}"); Console.WriteLine($"(is and interface)ball to interface:{ball is CONFLICT_INTERFACE}"); Console.WriteLine($"(is and interface)tools to interface:{tools is CONFLICT_INTERFACE}"); Console.WriteLine($"(as and interface)ball to interface:{ball as CONFLICT_INTERFACE}"); Console.WriteLine(ball.ToString()); Printer printer = new Printer("New"); Inventory[] children = new Inventory[] { inventory, ball, tools, printer, new Bars("Bars"), new Banch("Banch") }; foreach (var child in children) { printer.PrintClassData(child); } }
static void Main(string[] args) { Console.WriteLine("Enter budget"); try { int money = Convert.ToInt32(Console.ReadLine()); if (money < 0) { throw new InvalidArguments("Negative budget", money); } int tax = Convert.ToInt32(Console.ReadLine()); if (tax < 0) { throw new InvalidArguments("Negative tax", tax); } uint budget = Convert.ToUInt32(money) * (100 - Convert.ToUInt32(tax)); GYM container = new GYM(budget); Ball ball = new Ball("Pro-Universal", 30, Inventory.State.Used); Basketball basketball = new Basketball("Common-street", 8, Inventory.State.Used); Banch banch = new Banch("Level up for yourself", 79, Inventory.State.Used); Bars bars = new Bars("Some text", 60, Inventory.State.New); Ball ball1 = new Ball("asd", 2000, Inventory.State.New); container.Add(ball); container.Add(basketball); container.Add(banch); container.Add(bars); container.PrintToConsole(); Controller.SortInventory(container); Console.WriteLine("==================================================="); container.PrintToConsole(); Controller.FindFromRange(container, 2, 2); } catch (OutOfMemoryException e) { Console.WriteLine($"Memory exception:{e.Message}"); } catch (InvalidArguments e) { Console.WriteLine($"Invalid arguments detected\n" + $"Object:{e.Arg}\n" + $"Message:{e.Message}"); } catch (InvalidTypecast e) { Console.WriteLine($"Can't cast type:\n" + $"object type: {e.invalidObj.GetType()}\n" + $"Error message: {e.Message}"); } catch (ZERO e) { Console.WriteLine($"{e.Message}"); } catch (FileNotFoundException e) { Console.WriteLine(e.Message); } catch { Console.WriteLine($"Exception"); } finally { Console.WriteLine("Debug completed"); } }