Esempio n. 1
0
        static void Main(string[] args)
        {
            string[] firstInput = Console.ReadLine().Split();
            string   fullName   = $"{firstInput[0]} {firstInput[1]}";
            string   address    = firstInput[2];
            string   town       = firstInput[3];

            if (firstInput.Length > 4)
            {
                town += $" {firstInput[4]}";
            }
            CustomThreeuple <string, string, string> firstThreeuple =
                new CustomThreeuple <string, string, string>(fullName, address, town);

            string[] secondInput = Console.ReadLine().Split();
            string   secName     = secondInput[0];
            int      age         = int.Parse(secondInput[1]);
            bool     isDrunk     = secondInput[2] == "drunk";
            CustomThreeuple <string, int, bool> secondThreeuple =
                new CustomThreeuple <string, int, bool>(secName, age, isDrunk);

            string[] thirdInput     = Console.ReadLine().Split();
            string   thirdName      = thirdInput[0];
            double   accountBalance = double.Parse(thirdInput[1]);
            string   bankName       = thirdInput[2];
            CustomThreeuple <string, double, string> thirdThreeuple =
                new CustomThreeuple <string, double, string>(thirdName, accountBalance, bankName);

            Console.WriteLine(firstThreeuple);
            Console.WriteLine(secondThreeuple);
            Console.WriteLine(thirdThreeuple);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            string[] personInfo = Console.ReadLine().Split(" ");

            string names   = personInfo[0] + " " + personInfo[1];
            string address = personInfo[2];

            string town = string.Empty;

            if (personInfo.Length == 5)
            {
                town = personInfo[3] + " " + personInfo[4];
            }
            else
            {
                town = personInfo[3];
            }

            var firstCustomTuple = new CustomThreeuple <string, string, string>(names, address, town);

            string[] personBeerInfo = Console.ReadLine().Split(" ");

            string personName   = personBeerInfo[0];
            int    litersOfBeer = int.Parse(personBeerInfo[1]);
            string drunkInfo    = personBeerInfo[2];
            bool   drunkOrNot   = false;

            if (drunkInfo == "drunk")
            {
                drunkOrNot = true;
            }
            else
            {
                drunkOrNot = false;
            }

            var secondCustomTuple = new CustomThreeuple <string, int, bool>(personName, litersOfBeer, drunkOrNot);

            string[] bankInfo = Console.ReadLine().Split(" ");

            string name           = bankInfo[0];
            double accountBalance = double.Parse(bankInfo[1]);
            string bankName       = bankInfo[2];

            var thirdCustomTuple = new CustomThreeuple <string, double, string>(name, accountBalance, bankName);

            Console.WriteLine(firstCustomTuple);
            Console.WriteLine(secondCustomTuple);
            Console.WriteLine(thirdCustomTuple);
        }
        static void Main(string[] args)
        {
            string[] firstInput = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

            CustomThreeuple <string, string, string> nameAndAddress = new CustomThreeuple <string, string, string>();

            nameAndAddress.item1 = $"{firstInput[0]} {firstInput[1]}";
            nameAndAddress.item2 = $"{firstInput[2]}";

            if (firstInput.Length > 4)
            {
                nameAndAddress.item3 = $"{firstInput[3]} {firstInput[4]} ";
            }
            else
            {
                nameAndAddress.item3 = $"{firstInput[3]}";
            }

            string[] secondInput = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

            CustomThreeuple <string, int, bool> nameAndLitersOfBeer = new CustomThreeuple <string, int, bool>();

            nameAndLitersOfBeer.item1 = secondInput[0];
            nameAndLitersOfBeer.item2 = int.Parse(secondInput[1]);

            if (secondInput[2].ToLower() == "not")
            {
                nameAndLitersOfBeer.item3 = false;
            }
            else
            {
                nameAndLitersOfBeer.item3 = true;
            }

            string[] thirdInput = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries);

            CustomThreeuple <string, double, string> nameBalanceAndBank = new CustomThreeuple <string, double, string>();

            nameBalanceAndBank.item1 = thirdInput[0];
            nameBalanceAndBank.item2 = double.Parse(thirdInput[1]);
            nameBalanceAndBank.item3 = thirdInput[2];

            Console.WriteLine($"{nameAndAddress.item1} -> {nameAndAddress.item2} -> {nameAndAddress.item3}");
            Console.WriteLine($"{nameAndLitersOfBeer.item1} -> {nameAndLitersOfBeer.item2} -> {nameAndLitersOfBeer.item3}");
            Console.WriteLine($"{nameBalanceAndBank.item1} -> {nameBalanceAndBank.item2} -> {nameBalanceAndBank.item3}");
        }