Exemple #1
0
        static void Main(string[] args)
        {
            //Initialize the repository
            Race race = new Race("Indianapolis 500", 10);

            Console.WriteLine(race.GetOldestRacer());

            //Initialzie cars
            Car car1 = new Car("ferrari", 150);
            Car car2 = new Car("lambo", 170);

            //Initialize racer1
            Racer racer1 = new Racer("Stephen", 40, "Bulgaria", car1);

            //Print Racer
            Console.WriteLine(racer1); //Racer: Stephen, 40 (Bulgaria)

            //Add Racer
            race.Add(racer1);
            //Remove Racer
            race.Remove("Vin Benzin"); //false

            Racer racer2 = new Racer("Mark", 34, "UK", car2);

            //Add Racer
            race.Add(racer2);

            Racer oldestRacer  = race.GetOldestRacer();    // Racer with name Stephen
            Racer racerStephen = race.GetRacer("Stephen"); // Racer with name Stephen
            Racer fastestRacer = race.GetFastestRacer();   // Racer with name Mark

            Console.WriteLine(oldestRacer);                //Racer: Stephen, 40 (Bulgaria)
            Console.WriteLine(racerStephen);               //Racer: Stephen, 40 (Bulgaria)
            Console.WriteLine(fastestRacer);               // Racer: Mark, 34 (UK)
            Console.WriteLine(race.Count);                 //2

            Console.WriteLine(race.Report());
            //Racers working at Indianapolis 500:
            //Racer: Stephen, 40 (Bulgaria)
            //Racer: Mark, 34 (UK)
        }
Exemple #2
0
        public Racer GetOldestRacer()
        {
            Racer racer = racers.OrderByDescending(r => r.Age).FirstOrDefault();

            return(racer);
        }
Exemple #3
0
        public Racer GetFastestRacer()
        {
            Racer racer = racers.OrderByDescending(r => r.Car.Speed).FirstOrDefault();

            return(racer);
        }
Exemple #4
0
        public Racer GetRacer(string name)
        {
            Racer racer = data.FirstOrDefault(p => p.Name == name);

            return(racer);
        }
Exemple #5
0
        public Racer GetFastestRacer()
        {
            Racer racer = data.OrderByDescending(p => p.Car.Speed).FirstOrDefault();

            return(racer);
        }
Exemple #6
0
        public Racer GetRacer(string name)
        {
            Racer r = data.Where(r => r.Name == name).FirstOrDefault();

            return(r);
        }
Exemple #7
0
        public Racer GetFastestRacer()
        {
            Racer fastest = data.OrderByDescending(x => x.Car.Speed).FirstOrDefault();

            return(fastest);
        }
Exemple #8
0
        public Racer GetRacer(string name)
        {
            Racer currentRacer = racers.Find(x => x.Name == name);

            return(currentRacer);
        }
Exemple #9
0
        public Racer GetOldestRacer()
        {
            Racer oldest = data.OrderByDescending(x => x.Age).FirstOrDefault();

            return(oldest);
        }
        public Racer GetOldestRacer()
        {
            Racer racer = data.OrderByDescending(a => a.Age).FirstOrDefault();

            return(racer);
        }
Exemple #11
0
        public bool Remove(string name)
        {
            Racer current = data.FirstOrDefault(x => x.Name == name);

            return(data.Remove(current));
        }
Exemple #12
0
        public Racer GetRacer(string name)
        {
            Racer getRacer = Data.FirstOrDefault(x => x.Name == name);

            return(getRacer);
        }
Exemple #13
0
        public bool Remove(string name)
        {
            Racer findRacer = Data.FirstOrDefault(x => x.Name == name);

            return(Data.Remove(findRacer));
        }
        public bool Remove(string name)
        {
            Racer curRac = data.Find(x => x.Name == name);

            return(data.Remove(curRac));
        }