Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Bronze bronzeCard = new Bronze(0.0, 150.0);

            if (bronzeCard.Turnover > 300.0)
            {
                bronzeCard.DiscountRate = 0.025;
            }
            else if (bronzeCard.Turnover >= 100)
            {
                bronzeCard.DiscountRate = 0.01;
            }
            Silver silverCard = new Silver(600.0, 850.0);

            if (silverCard.Turnover > 300)
            {
                silverCard.DiscountRate = 0.035;
            }
            Gold goldCard = new Gold(1500.0, 1300.0);

            if (goldCard.Turnover > 100)
            {
                if (goldCard.Turnover / 100 > 10)
                {
                    goldCard.DiscountRate = 0.10;
                }
                else
                {
                    goldCard.DiscountRate = goldCard.Turnover / 10000;
                }
            }
            Console.WriteLine(bronzeCard);
            Console.WriteLine(silverCard);
            Console.WriteLine(goldCard);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //test input for turnover for the previous month and value of purchase to calculate the discount
            double prevMonthTurnonver = 600;
            double valueOfPurchase    = 850;

            // initialize classes

            DiscountCard card   = new DiscountCard(prevMonthTurnonver);
            Bronze       bronze = new Bronze(prevMonthTurnonver);

            bronze.PurchaseValue += valueOfPurchase;
            Silver silver = new Silver(prevMonthTurnonver);

            silver.PurchaseValue += valueOfPurchase;
            Gold gold = new Gold(prevMonthTurnonver);

            gold.PurchaseValue += valueOfPurchase;

            //use whatever you want with implemented paydesk methods
            PayDesk paydesk = new PayDesk(silver);

            paydesk.Discount();
            paydesk.DiscountRate();

            //Console.WriteLine(bronze.PrintOwnerInfo());
            //Console.WriteLine(silver.PrintOwnerInfo());
            //Console.WriteLine(gold.PrintOwnerInfo());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var bronzeCard = new Bronze("Stefan Panchev", 0);
            var goldCard   = new Gold("Konstan Jelqzkov", 1500);
            var silverCard = new Silver("Nikolаоs Citiridis", 600);

            var purchaseWithBtonze = new Purchase(150, bronzeCard);
            var purchaseWithSilver = new Purchase(850, silverCard);
            var purchaseWithGold   = new Purchase(1300, goldCard);

            Console.WriteLine(purchaseWithBtonze.ToString());
            Console.WriteLine(purchaseWithSilver.ToString());
            Console.WriteLine(purchaseWithGold.ToString());
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            //Enters value for the turnover and guaranteed that it is not negative.
            Console.WriteLine("Please enter the turnover for the previous month:");
            decimal turnover = decimal.Parse(Console.ReadLine());

            while (turnover < 0)
            {
                Console.WriteLine("The turnover should be higher than 0");
                turnover = decimal.Parse(Console.ReadLine());
            }

            //Enters value for the purchase value.
            Console.WriteLine("Please enter the purchase value:");
            decimal purchaseValue = decimal.Parse(Console.ReadLine());

            //Chooses which kind of card we prefer.
            Console.WriteLine("Please enter the type of discount card:");
            string typeOfCard = Console.ReadLine();

            while (!(typeOfCard == "Bronze" || typeOfCard == "Silver" || typeOfCard == "Gold"))
            {
                Console.WriteLine("Invalid discount card type. Please choose between following: Bronze, Silver and Gold");
                typeOfCard = Console.ReadLine();
            }

            if (typeOfCard == "Bronze")
            {
                //If we choose bronze card ,the program comes here.
                Bronze bronzeCard = new Bronze();
                bronzeCard.BronzCardDiscount(turnover, purchaseValue);
                PayDesk.Print(bronzeCard.PurchaseValue, bronzeCard.DiscountRate, bronzeCard.Discount, bronzeCard.TotalSum, bronzeCard.TypeOfCard);
            }
            else if (typeOfCard == "Silver")
            {
                //If we choose silver card ,the program comes here.
                Silver silverCard = new Silver();
                silverCard.SilverCardDiscount(turnover, purchaseValue);
                PayDesk.Print(silverCard.PurchaseValue, silverCard.DiscountRate, silverCard.Discount, silverCard.TotalSum, silverCard.TypeOfCard);
            }
            else if (typeOfCard == "Gold")
            {
                //If we choose gold card ,the program comes here.
                Gold goldCard = new Gold();
                goldCard.GoldCardDiscount(turnover, purchaseValue);
                PayDesk.Print(goldCard.PurchaseValue, goldCard.DiscountRate, goldCard.Discount, goldCard.TotalSum, goldCard.TypeOfCard);
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Bronze bronze = new Bronze(0);

            bronze.Calculate(150);

            Silver silver = new Silver(600);

            silver.Calculate(850);

            Gold gold = new Gold(1500);

            gold.Calculate(1300);

            Console.ReadKey();
        }
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            try
            {
                Bronze bronzeCard = new Bronze(0, 150);
                Silver silverCard = new Silver(600, 850);
                Gold   goldCard   = new Gold(1500, 1300);

                Console.WriteLine($"1. Bronze {Environment.NewLine}{bronzeCard}");
                Console.WriteLine($"2. Silver {Environment.NewLine}{silverCard}");
                Console.WriteLine($"3. Gold {Environment.NewLine}{goldCard}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            Bronze bronze = new Bronze(0, 150);

            bronze.Print();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Silver silver = new Silver(600, 850);

            silver.Print();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Gold gold = new Gold(1500, 1300);

            gold.Print();
        }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            Cards       gold     = new Gold("10/26/2020");
            Client      rober    = new Client("Stojan", "Stojadinovic", "23.2.1999", "255255", gold);
            MarketStore pawnShop = new MarketStore(rober);

            pawnShop.Purchaseitem();

            Cards       silver         = new Silver("10/26/2020");
            Client      Mileva         = new Client("Mileva", "Mojic", "23.2.1999", "255255", silver);
            MarketStore pawnShopMaster = new MarketStore(Mileva);

            Cards       bronze              = new Bronze("10/26/2020");
            Client      roberti             = new Client("Stojan", "Stojadinovic", "23.2.1999", "255255", bronze);
            MarketStore pawnShopMasterElite = new MarketStore(roberti);


            Console.ReadLine();
        }
Exemplo n.º 9
0
 static void Main(string[] args)
 {
     try
     {
         Bronze bronze = new Bronze("Jelena", "Cvetkovic", 0);
         Silver silver = new Silver("Jelena", "Cvetkovic", 600);
         Gold   gold   = new Gold("Jelena", "Cvetkovic", 1500);
         Console.WriteLine(bronze.Purchase(150));
         Console.WriteLine(silver.Purchase(850));
         Console.WriteLine(gold.Purchase(1300));
     }
     catch (ArgumentOutOfRangeException e)
     {
         Console.WriteLine(e.Message);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Exemplo n.º 10
0
        public static void Main(string[] args)
        {
            Owner ownerOne   = new Owner("Petar Petrov");
            Owner ownerTwo   = new Owner("Dimitar Stoev");
            Owner ownerThree = new Owner("Alex Alenov");

            ICard cardOne   = new Bronze(ownerThree, 0);
            ICard cardTwo   = new Silver(ownerOne, 600);
            ICard cardThree = new Gold(ownerTwo, 1500);
            ICard cardFour  = new Bronze(ownerOne, 302);
            ICard cardFive  = new Silver(ownerTwo, 212);
            ICard cardSix   = new Gold(ownerTwo, 750);

            Console.WriteLine(cardOne.Output(150));
            Console.WriteLine(cardTwo.Output(850));
            Console.WriteLine(cardThree.Output(1300));
            Console.WriteLine(cardFour.Output(199));
            Console.WriteLine(cardFive.Output(342));
            Console.WriteLine(cardSix.Output(187));
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            Card bronze = new Bronze()
            {
                PurchaseValue = 150.00,
                Turnover      = 0
            };
            Card silver = new Silver()
            {
                PurchaseValue = 850.00,
                Turnover      = 600.00
            };
            Card gold = new Gold()
            {
                PurchaseValue = 1300.00,
                Turnover      = 1500.00
            };


            bronze.GetDiscountRate(bronze);
            silver.GetDiscountRate(silver);
            gold.GetDiscountRate(gold);
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            int number = 0;

            //Type of card
            do
            {
                Console.WriteLine("What kind of car do you have?");
                Console.WriteLine("1.Bronze , 2.Silver, 3.Gold");
                Console.Write("Enter card type:");
                try
                {
                    number = int.Parse(Console.ReadLine());

                    if (!(1 <= number && number <= 3))
                    {
                        Console.WriteLine("Try with correct value!");
                    }
                }

                catch
                {
                    Console.WriteLine("Incorrect format!");
                }
            } while (!(1 <= number && number <= 3));

            //Turnover
            float mockData = -1;

            do
            {
                Console.Write("Enter mock data: $");

                try
                {
                    mockData = float.Parse(Console.ReadLine());

                    if (mockData < 0)
                    {
                        Console.WriteLine("The value cannot be negative!");
                    }
                }

                catch
                {
                    Console.WriteLine("Incorrect format!");
                }
            } while (!(mockData > 0));

            float purchValue = -1;

            //Purchase value
            do
            {
                Console.Write("Enter purchase value: $");

                try
                {
                    purchValue = float.Parse(Console.ReadLine());

                    if (purchValue < 0)
                    {
                        Console.WriteLine("The value cannot be negative!");
                    }
                }

                catch
                {
                    Console.WriteLine("Incorrect format!");
                }
            } while (!(mockData > 0));

            //Create object 1.Bronze , 2.Silver, 3.Gold
            switch (number)
            {
            case 1:
            {
                Bronze bronzeCard = new Bronze(mockData, purchValue);
                bronzeCard.PrintReceipt();
                break;
            }

            case 2:
            {
                Silver silverCard = new Silver(mockData, purchValue);
                silverCard.PrintReceipt();
                break;
            }

            case 3:
            {
                Gold goldCard = new Gold(mockData, purchValue);
                goldCard.PrintReceipt();
                break;
            }
            }
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            // Creating object of Bronze card and giving to it Turnover and Purchase values
            Bronze bronze = new Bronze();

            // Case Prime
            bronze.Turnover      = 0.0;
            bronze.PurchaseValue = 150.0;

            /* Case 1
             * bronze.Turnover = 90.0;
             * bronze.PurchaseValue = 1000.0; */

            /* Case 2
             * bronze.Turnover = 250.0;
             * bronze.PurchaseValue = 1000.0;  */

            /* Case 3
             * bronze.Turnover = 350.0;
             * bronze.PurchaseValue = 1000.0; */

            /* Case ERR
             * bronze.Turnover = -150.0;
             * bronze.PurchaseValue = 1000.0; */

            Console.WriteLine(bronze.report(bronze.PurchaseValue).ToString());


            // Creating object of Silver card and giving to it Turnover and Purchase values
            Silver silver = new Silver();

            // Case Prime
            silver.Turnover      = 600.0;
            silver.PurchaseValue = 850.0;

            /* Case 1
             * silver.Turnover = 250.0;
             * silver.PurchaseValue = 1000.0; */

            /* Case 2
             * silver.Turnover = 1000.0;
             * silver.PurchaseValue = 1000.0; */

            /* Case ERR
             * silver.Turnover = -1000.0;
             * silver.PurchaseValue = 1000.0; */

            Console.WriteLine(silver.report(silver.PurchaseValue).ToString());


            // Creating object od Gold card and giving to it Turnover and Purchase values
            Gold gold = new Gold();

            // Case Prime
            gold.Turnover      = 1500.0;
            gold.PurchaseValue = 1300.0;

            /* Case 1
             * gold.Turnover = 90.0;
             * gold.PurchaseValue = 1000.0; */

            /* Case 2
             * gold.Turnover = 100.0;
             * gold.PurchaseValue = 1000.0; */

            /* Case 3
             * gold.Turnover = 650.0;
             * gold.PurchaseValue = 1000.0; */

            /* Case 4
             * gold.Turnover = 950.0;
             * gold.PurchaseValue = 1000.0; */

            /* Case ERR
             * gold.Turnover = -1505.0;
             * gold.PurchaseValue = 1000.0; */

            Console.WriteLine(gold.report(gold.PurchaseValue).ToString());
            Console.ReadKey();
        }
Exemplo n.º 14
0
        public static void InsertDataInDatabase()
        {
            try
            {
                SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
                builder.DataSource     = "(LocalDb)\\MSSQLLocalDB"; // update me
                builder.UserID         = "";                        // update me
                builder.Password       = "";                        // update me
                builder.InitialCatalog = "martketStoreDB";
                using (MarketContext context = new MarketContext(builder.ConnectionString))
                {
                    Bronze Bronze = new Bronze {
                        Id = 1, Turnover = 0, Discount = 0, User_Id = 1
                    };
                    GetData.valueOfPurchase(Bronze, 150);
                    try
                    {
                        context.Bronze.Add(Bronze);
                        context.SaveChanges();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine(e.ToString());
                    }

                    Silver Silver = new Silver {
                        Id = 1, Turnover = 600, Discount = 2, User_Id = 2
                    };
                    GetData.valueOfPurchase(Silver, 850);
                    try
                    {
                        context.Silver.Add(Silver);
                        context.SaveChanges();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine(e.ToString());
                    }

                    Gold Gold = new Gold {
                        Id = 1, Turnover = 1500, Discount = 2, User_Id = 3
                    };
                    GetData.valueOfPurchase(Gold, 1300);
                    try
                    {
                        context.Gold.Add(Gold);
                        context.SaveChanges();
                    }
                    catch (SqlException e)
                    {
                        Console.WriteLine(e.ToString());
                    }

                    Console.WriteLine("Done");
                }
            }
            catch (SqlException e)
            {
                Console.WriteLine(e.ToString());
            }
        }