Esempio n. 1
0
        static void Main(string[] args)
        {
            List <IBuyer> people = new List <IBuyer>();
            int           count  = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; i++)
            {
                string[] input = Console.ReadLine()
                                 .Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

                if (input.Length == 3)
                {
                    people.Add(new Rebel(input[0], input[1], input[2]));
                }
                else
                {
                    people.Add(new Citizen(input[0], input[1], input[2], input[3]));
                }
            }

            string command = string.Empty;

            while ((command = Console.ReadLine()) != "End")
            {
                if (people.Any(x => x.Name == command))
                {
                    IBuyer toAddFood = people.Find(x => x.Name == command);
                    toAddFood.BuyFood();
                }
            }

            int allFood = people.Sum(x => x.Food);

            Console.WriteLine(allFood);
        }
Esempio n. 2
0
    public static void Main()
    {
        List <IBuyer> buyers = new List <IBuyer>();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            string[] tokens = Console.ReadLine()
                              .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            AddCitizensAndRebelsToList(buyers, tokens);
        }

        string inputName = Console.ReadLine();

        while (inputName != "End")
        {
            IBuyer buyer = buyers.FirstOrDefault(b => b.Name == inputName);
            if (buyer != null)
            {
                buyer.BuyFood();
            }

            inputName = Console.ReadLine();
        }

        Console.WriteLine(buyers.Sum(f => f.Food));
    }
Esempio n. 3
0
    static void Main(string[] args)
    {
        List <IBuyer> buyableCreatures = new List <IBuyer>();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            string input  = Console.ReadLine();
            var    tokens = input.Split();
            if (tokens.Length == 4)
            {
                buyableCreatures.Add(new Citizent(tokens[0], int.Parse(tokens[1]), tokens[2], tokens[3]));
            }
            else
            {
                buyableCreatures.Add(new Rebel(tokens[0], int.Parse(tokens[1]), tokens[2]));
            }
        }

        string name;

        while ((name = Console.ReadLine()) != "End")
        {
            if (buyableCreatures.Any(x => x.Name == name) == false)
            {
                continue;
            }
            IBuyer buyer = buyableCreatures.Single(x => x.Name == name);
            buyer.BuyFood();
        }
        Console.WriteLine(buyableCreatures.Sum(x => x.Food));
    }
 public PaymentsDataBusinessImpl(IClient client, IBuyer buyer, ICard card, IPayment payment)
 {
     _client  = client;
     _buyer   = buyer;
     _card    = card;
     _payment = payment;
 }
Esempio n. 5
0
    public static void Main()
    {
        int buyersCount = int.Parse(Console.ReadLine());

        Dictionary <string, IBuyer> buyersByName = new Dictionary <string, IBuyer>();

        for (int i = 0; i < buyersCount; i++)
        {
            string[] buyerParams = Console.ReadLine().Split();

            IBuyer buyer = GetBuyer(buyerParams);

            string personName = buyerParams[0];

            buyersByName[personName] = buyer;
        }

        string buyerName = null;

        while ((buyerName = Console.ReadLine()) != "End")
        {
            if (buyersByName.ContainsKey(buyerName))
            {
                buyersByName[buyerName].BuyFood();
            }
        }

        int totalAmountOfFoodPurchased = buyersByName.Sum(person => person.Value.Food);

        Console.WriteLine(totalAmountOfFoodPurchased);
    }
Esempio n. 6
0
        public static void GetTotalFood(List <IObject> objects)
        {
            int totalFoodBought = 0;

            while (true)
            {
                string name = Console.ReadLine();
                if (name == "End")
                {
                    break;
                }

                IBuyer buyer = (IBuyer)objects.FirstOrDefault(x => x.Name == name);
                if (buyer != null)
                {
                    buyer.BuyFood();
                }
            }
            foreach (var item in objects)
            {
                IBuyer buyer = (IBuyer)item;
                totalFoodBought += buyer.Food;
            }
            Console.WriteLine(totalFoodBought);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            List <IBuyer> buyers         = new List <IBuyer>();
            int           numberOfPeople = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfPeople; i++)
            {
                string[] info = Console.ReadLine().Split();
                if (info.Length == 3)
                {
                    IBuyer rebel = new Rebel(info[0], int.Parse(info[1]), info[2]);
                    buyers.Add(rebel);
                }
                if (info.Length == 4)
                {
                    IBuyer citizen = new Citizen(info[0], int.Parse(info[1]), info[2], info[3]);
                    buyers.Add(citizen);
                }
            }
            string name = string.Empty;

            while ((name = Console.ReadLine()) != "End")
            {
                if (buyers.Any(b => b.Name == name))
                {
                    IBuyer buyer = buyers.FirstOrDefault(b => b.Name == name);
                    buyer.BuyFood();
                }
            }
            int totalFood = buyers.Sum(b => b.Food);

            Console.WriteLine(totalFood);
        }
        public static void Main()
        {
            List <IPerson> people = new List <IPerson>();

            int inputLines = int.Parse(Console.ReadLine());

            for (int i = 0; i < inputLines; i++)
            {
                string[] personArgs = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).ToArray();

                AddPerson(personArgs, people);
            }


            HashSet <IBuyer> buyers     = new HashSet <IBuyer>();
            string           personName = Console.ReadLine();

            while (personName.ToLower() != "end")
            {
                if (IsAnExistingName(personName, people))
                {
                    IBuyer buyer = (IBuyer)people.Where(p => p.Name == personName).FirstOrDefault();
                    buyer.BuyFood();
                    buyers.Add(buyer);
                }

                personName = Console.ReadLine();
            }

            int sum = GetSumOfAllFood(buyers);

            Console.WriteLine(sum);
        }
Esempio n. 9
0
        public static void Main()
        {
            List <IBuyer> people = new List <IBuyer>();

            int number = int.Parse(Console.ReadLine());

            for (int i = 0; i < number; i++)
            {
                string[] information = Console.ReadLine().Split();

                if (information.Length == 4)
                {
                    string name      = information[0];
                    int    age       = int.Parse(information[1]);
                    string id        = information[2];
                    string birthdate = information[3];
                    IBuyer human     = new Human(name, age, id, birthdate);
                    people.Add(human);
                }
                else if (information.Length == 3)
                {
                    string name  = information[0];
                    int    age   = int.Parse(information[1]);
                    string group = information[2];
                    IBuyer buyer = new Rebel(name, age, group);
                    people.Add(buyer);
                }
            }

            string        buyingFood = Console.ReadLine();
            List <string> names      = new List <string>();

            while (buyingFood != "End")
            {
                names.Add(buyingFood);

                buyingFood = Console.ReadLine();
            }

            foreach (var name in names)
            {
                if (people.Any(x => x.Name == name))
                {
                    IBuyer person = people.FirstOrDefault(x => x.Name == name);
                    person.BuyFood();
                }
            }

            int sumFood = 0;

            foreach (var person in people)
            {
                sumFood += person.Food;
            }

            Console.WriteLine(sumFood);
        }
 public ProductionController(ISalesInvoice sales, IProduct product, IBuyer buyer, IProduction production, PermessDbContext context, IStock stock)
 {
     _sales      = sales;
     _product    = product;
     _buyer      = buyer;
     _production = production;
     _context    = context;
     _stock      = stock;
 }
        public BusinessLogic_Documents()
        {
            container = DI_Container.Config();

            receiptProcessor = container.Resolve <IReceiptProcessor>();
            invoiceProcessor = container.Resolve <IInvoiceProcessor>();
            vendor           = container.Resolve <IVendor>();
            buyer            = container.Resolve <IBuyer>();
            invoice          = container.Resolve <IInvoice>();
        }
Esempio n. 12
0
 //string code = "";
 public SalesController(IBuyer buyer, ISalesInvoice sales, IProduct product, IPurchase purchase, PermessDbContext context, IStock stock, IPermess permess)
 {
     _buyer    = buyer;
     _sales    = sales;
     _product  = product;
     _purchase = purchase;
     _context  = context;
     _stock    = stock;
     _permess  = permess;
 }
 public PermessDataController(IBuyer buyer, IProduct product, IStock stock, IPermess permess, ISalesInvoice sales, PermessDbContext context, ISystemUser user)
 {
     _buyer   = buyer;
     _product = product;
     _stock   = stock;
     _permess = permess;
     _sales   = sales;
     _context = context;
     _user    = user;
 }
Esempio n. 14
0
    static void Main(string[] args)
    {
        ICollection <IBuyer> person = new List <IBuyer>();

        int count = int.Parse(Console.ReadLine());

        IBuyer nameBuyer = null;

        for (int i = 0; i < count; i++)
        {
            string[] personName = Console.ReadLine().Split();
            string   name       = personName[0];

            if (personName.Length == 4)
            {
                nameBuyer = new Citizen(name);
                person.Add(nameBuyer);
            }
            else if (personName.Length == 3)
            {
                nameBuyer = new Rebel(name);
                person.Add(nameBuyer);
            }
        }

        ICollection <string> names = new List <string>();
        string nameQueue           = string.Empty;

        while ((nameQueue = Console.ReadLine()) != "End")
        {
            names.Add(nameQueue);
        }

        int sumFood = 0;

        foreach (var trueName in person.Where(n => n is Citizen))
        {
            foreach (var allName in names)
            {
                trueName.BuyFood(allName);
            }
            sumFood += trueName.Food;
        }

        foreach (var trueName in person.Where(n => n is Rebel))
        {
            foreach (var allName in names)
            {
                trueName.BuyFood(allName);
            }
            sumFood += trueName.Food;
        }

        Console.WriteLine(sumFood);
    }
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            Dictionary <string, IBuyer> buyers = new Dictionary <string, IBuyer>();

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);

                if (input.Length == 4)
                {
                    string name      = input[0];
                    int    age       = int.Parse(input[1]);
                    string id        = input[2];
                    string birthdate = input[3];

                    buyers[name] = new Citizen(name, age, id, birthdate);
                }
                else if (input.Length == 3)
                {
                    string name  = input[0];
                    int    age   = int.Parse(input[1]);
                    string group = input[2];

                    buyers[name] = new Rebel(name, age, group);
                }
            }



            while (true)
            {
                string name = Console.ReadLine();

                if (name == "End")
                {
                    break;
                }

                if (!buyers.ContainsKey(name))
                {
                    continue;
                }

                IBuyer buyer = buyers[name];

                buyer.BuyFood();
            }

            var total = buyers.Values.Sum(b => b.Food);

            Console.WriteLine(total);
        }
Esempio n. 16
0
 public void BuyFood(IBuyer buyer)
 {
     if (buyer is Rebel)
     {
         Food += Rebel.CAPACITY;
     }
     else
     {
         Food += Citizen.CAPACITY;
     }
 }
Esempio n. 17
0
        static void Main(string[] args)
        {
            List <IBuyer> citizens = new List <IBuyer>();

            int numberOfOperations = int.Parse(Console.ReadLine());

            for (int i = 0; i < numberOfOperations; i++)
            {
                string   input   = Console.ReadLine();
                string[] cmdArgs = input.Split();

                if (cmdArgs.Length == 4)
                {
                    string name      = cmdArgs[0];
                    int    age       = int.Parse(cmdArgs[1]);
                    string id        = cmdArgs[2];
                    string birthdate = cmdArgs[3];
                    citizens.Add(new Citizen(name, age, id, birthdate));
                }
                else if (cmdArgs.Length == 3)
                {
                    string name  = cmdArgs[0];
                    int    age   = int.Parse(cmdArgs[1]);
                    string group = cmdArgs[2];
                    citizens.Add(new Rebel(name, age, group));
                }
            }

            int sum = 0;

            while (true)
            {
                string line = Console.ReadLine();

                if (line == "End")
                {
                    break;
                }

                IBuyer buyer = citizens.Find(x => x.Name == line);

                if (buyer != null)
                {
                    buyer.BuyFood();
                }
            }

            foreach (var item in citizens)
            {
                sum += item.Food;
            }

            Console.WriteLine(sum);
        }
Esempio n. 18
0
        public void Run()
        {
            int count = int.Parse(Console.ReadLine());

            for (int i = 0; i < count; i++)
            {
                string[] commandArgs = Console.ReadLine()
                                       .Split();

                if (commandArgs.Length == 4)
                {
                    string name      = commandArgs[0];
                    int    age       = int.Parse(commandArgs[1]);
                    string id        = commandArgs[2];
                    string birthdate = commandArgs[3];

                    IBuyer buyer = new Citizen(name, age, id, birthdate);

                    this.buyers.Add(buyer);
                }
                else if (commandArgs.Length == 3)
                {
                    string name  = commandArgs[0];
                    int    age   = int.Parse(commandArgs[1]);
                    string group = commandArgs[2];

                    IBuyer buyer = new Rebel(name, age, group);

                    this.buyers.Add(buyer);
                }
            }

            int totalFood = 0;

            string command = Console.ReadLine();

            while (command != "End")
            {
                string name = command;

                IBuyer buyer = this.buyers.FirstOrDefault(b => b.Name == name);

                if (buyer != null)
                {
                    totalFood += -buyer.Food + buyer.BuyFood();
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(totalFood);
        }
Esempio n. 19
0
    private static void EnterRebel(string[] data)
    {
        string name  = data[0];
        int    age   = int.Parse(data[1]);
        string group = data[2];
        Rebel  rebel = new Rebel(name, age, group);
        IBuyer buyer = buyers.FirstOrDefault(r => r.Name == name);

        if (buyer == null)
        {
            buyers.Add(rebel);
        }
    }
Esempio n. 20
0
        private static void BuyFoods(List <IBuyer> buyers)
        {
            string input;

            while ((input = Console.ReadLine()) != "End")
            {
                IBuyer buyer = buyers.FirstOrDefault(b => b.Name == input);
                if (buyer != null)
                {
                    buyer.BuyFood();
                }
            }
        }
        public void InvoiceListNew(List <ISaleItem> list, IBuyer buyer, IVendor vendor, IInvoice invoice)
        {
            InvoiceDocument i = new InvoiceDocument();

            //i.InvoiceOrder(invoice); // wyjście do numeracji, po odczycie z bazy danych

            i.InvoiceVendor(vendor);

            i.InvoiceBuyer(buyer);

            i.InvoiceListData(list);

            i.Show();
        }
Esempio n. 22
0
    private static void BuyFood()
    {
        string name = "";

        while ((name = Console.ReadLine()) != "End")
        {
            IBuyer buyer = buyers.FirstOrDefault(r => r.Name == name);
            if (buyer != null)
            {
                buyer.BuyFood();
                continue;
            }
        }
    }
Esempio n. 23
0
    private static void EnterCitizen(string[] data)
    {
        string  name      = data[0];
        int     age       = int.Parse(data[1]);
        string  id        = data[2];
        string  birthdate = data[3];
        Citizen citizen   = new Citizen(id, name, age, birthdate);
        IBuyer  buyer     = buyers.FirstOrDefault(r => r.Name == name);

        if (buyer == null)
        {
            buyers.Add(citizen);
        }
    }
Esempio n. 24
0
        public static void Main(string[] args)
        {
            Dictionary <string, IBuyer> buyersByName = new Dictionary <string, IBuyer>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] data = Console.ReadLine().Split();

                if (data.Length == 3)
                {
                    string name  = data[0];
                    int    age   = int.Parse(data[1]);
                    string group = data[2];

                    buyersByName[name] = new Rebel(name, age, group);
                }
                else
                {
                    string name      = data[0];
                    int    age       = int.Parse(data[1]);
                    string id        = data[2];
                    string birthdate = data[3];

                    buyersByName[name] = new Citizen(name, age, id, birthdate);
                }
            }

            while (true)
            {
                string line = Console.ReadLine();
                if (line == "End")
                {
                    break;
                }

                if (!buyersByName.ContainsKey(line))
                {
                    continue;
                }

                IBuyer buyer = buyersByName[line];
                buyer.BuyFood();
            }

            var totalAmountFood = buyersByName.Values.Sum(b => b.Food);

            Console.WriteLine(totalAmountFood);
        }
Esempio n. 25
0
 public InventoryDataController(IBuyer buyer, IInventorySetting inventorySetting, ISession session, ISalesInvoice salesInvoice, IPurchaseInvoice purchase, IPurchaseReturn purchaseReturn, ISalesReturn salesReturn, IDuePayment payment, IReport report, ISupplier supplier, DataContext context)
 {
     _buyer            = buyer;
     _inventorySetting = inventorySetting;
     _session          = session;
     _salesInvoice     = salesInvoice;
     _purchase         = purchase;
     _purchaseReturn   = purchaseReturn;
     _salesReturn      = salesReturn;
     _payment          = payment;
     _report           = report;
     _supplier         = supplier;
     _context          = context;
 }
Esempio n. 26
0
        static void Main(string[] args)
        {
            List <IBuyer> people = new List <IBuyer>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] info = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

                if (info.Length == 4)
                {
                    string name      = info[0];
                    int    age       = int.Parse(info[1]);
                    string id        = info[2];
                    string birthdate = info[3];

                    Citizen citizen = new Citizen(name, age, id, birthdate);
                    people.Add(citizen);
                }
                else
                {
                    string name  = info[0];
                    int    age   = int.Parse(info[1]);
                    string group = info[2];

                    Rebel rebel = new Rebel(name, age, group);
                    people.Add(rebel);
                }
            }

            while (true)
            {
                string input = Console.ReadLine();

                if (input == "End")
                {
                    break;
                }

                IBuyer person = people.FirstOrDefault(n => n.Name == input);

                if (person != null)
                {
                    person.BuyFood();
                }
            }

            Console.WriteLine(people.Sum(p => p.Food));
        }
Esempio n. 27
0
        public static void Main(string[] args)
        {
            int           n      = int.Parse(Console.ReadLine());
            List <IBuyer> result = new List <IBuyer>();

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split();

                switch (input.Length)
                {
                case 4:
                    string name      = input[0];
                    string age       = input[1];
                    string id        = input[2];
                    string birthdate = input[3];

                    Citizen citizen = new Citizen(name, age, id, birthdate);
                    result.Add(citizen);
                    break;

                case 3:
                    string rebelName  = input[0];
                    string rebelAge   = input[1];
                    string rebelGroup = input[2];

                    Rebel rebel = new Rebel(rebelName, rebelAge, rebelGroup);
                    result.Add(rebel);
                    break;
                }
            }

            string command = Console.ReadLine();

            while (command != "End")
            {
                string name = command;

                if (result.Any(x => x.Name == name))
                {
                    IBuyer item = result.FirstOrDefault(x => x.Name == name);
                    item.BuyFood();
                }

                command = Console.ReadLine();
            }

            Console.WriteLine(result.Sum(x => x.Food));
        }
Esempio n. 28
0
        public static void Main(string[] args)
        {
            HashSet <IBuyer> creatures = new HashSet <IBuyer>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string   inputCreature = Console.ReadLine();
                string[] creatureInfo  = inputCreature.Split();

                string name = creatureInfo[0];
                int    age  = int.Parse(creatureInfo[1]);

                if (creatureInfo.Length == 4)
                {
                    string id        = creatureInfo[2];
                    string birthdate = creatureInfo[3];

                    IBuyer creature = new Citizen(name, age, id, birthdate);
                    creatures.Add(creature);
                }

                else if (creatureInfo.Length == 3)
                {
                    string group    = creatureInfo[2];
                    IBuyer creature = new Rebel(name, age, group);
                    creatures.Add(creature);
                }
            }

            string input = Console.ReadLine();

            int foodSum = 0;

            while (input != "End")
            {
                IBuyer targetCitizen = creatures.FirstOrDefault(c => c.Name == input);

                if (targetCitizen != null)
                {
                    foodSum += targetCitizen.BuyFood();
                }

                input = Console.ReadLine();
            }

            Console.WriteLine(foodSum);
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            List <IBuyer> citizensAndRebels = new List <IBuyer>();

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] info = Console.ReadLine().Split();

                if (info.Length == 3)
                {
                    string name  = info[0];
                    int    age   = int.Parse(info[1]);
                    string group = info[2];

                    Rebel rebel = new Rebel(name, age, group);

                    citizensAndRebels.Add(rebel);
                }
                else if (info.Length == 4)
                {
                    string name      = info[0];
                    int    age       = int.Parse(info[1]);
                    string id        = info[2];
                    string birthdate = info[3];

                    Citizen citizen = new Citizen(name, age, id, birthdate);
                    citizensAndRebels.Add(citizen);
                }
            }

            string input = Console.ReadLine();

            while (input != "End")
            {
                IBuyer citizenOrRebel = citizensAndRebels.FirstOrDefault(n => n.Name == input);
                if (citizenOrRebel != null)
                {
                    citizenOrRebel.BuyFood();
                }

                input = Console.ReadLine();
            }

            int totalFood = citizensAndRebels.Sum(n => n.Food);

            Console.WriteLine(totalFood);
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            var peoples = ReadBuyers();

            string name = Console.ReadLine();

            while (name != "End")
            {
                IBuyer buyer = peoples.FirstOrDefault(n => n.Name == name);
                buyer?.BuyFood();
                name = Console.ReadLine();
            }

            Console.WriteLine(peoples.Sum(p => p.Food));
        }
        public MainPresenter(IMainfForm view, IMachine machineActionsManager, IBuyer buyer)
        {
            _view = view;
            _machineActionsManager = machineActionsManager;
            _buyer = buyer;
            _view.setBuyerSum(150);

            _view.radio10Click += _view_radio10Click;
            _view.radio5Click += _view_radio5Click;
            _view.radio2Click += _view_radio2Click;
            _view.radio1Click += _view_radio1Click;

            _view.insertCoin += _view_insertCoin;

            _view.takeProductsClick += _view_takeProductsClick;
            _view.takeChangeClick += _view_takeChangeClick;
        }