예제 #1
0
        public void getTraid()
        {
            Console.Clear();
            warior.getInfo();
            Console.WriteLine("What do you want to buy:\n1.{0}({1} coins)\n2.{2}({3} coins)\n3.{4}({5} coins)\n4.{6}({7} coins)\n5.No", knife.getName(), knife.getPrice(), sword.getName(),
                              sword.getPrice(), rags.getName(), rags.getPrice(), tunic.getName(), tunic.getPrice());
            switch (Console.ReadLine())
            {
            case "1":
                if (warior.getMoney() >= knife.getPrice())
                {
                    warior.setWeapon(knife);
                    warior.setMoney(warior.getMoney() - knife.getPrice());
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Not enought money!!");
                    Console.ReadKey();
                }
                break;

            case "2":
                if (warior.getMoney() >= sword.getPrice())
                {
                    warior.setWeapon(sword);
                    warior.setMoney(warior.getMoney() - sword.getPrice());
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Not enought money!!");
                    Console.ReadKey();
                }
                break;

            case "3":
                if (warior.getMoney() >= rags.getPrice())
                {
                    warior.setArmor(rags);
                    warior.setMoney(warior.getMoney() - rags.getPrice());
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Not enought money!!");
                    Console.ReadKey();
                }
                break;

            case "4":
                if (warior.getMoney() >= tunic.getPrice())
                {
                    warior.setArmor(tunic);
                    warior.setMoney(warior.getMoney() - tunic.getPrice());
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("Not enought money!!");
                    Console.ReadKey();
                }
                break;

            default:
                Console.Clear();
                Console.WriteLine("Bye");
                Console.ReadKey();
                break;
            }
        }
예제 #2
0
 public void giveMoney()
 {
     player.setMoney(player.getMoney() + 10);
 }