示例#1
0
        static void Main(string[] args)
        {
            Criminal[] criminals = new Criminal[3];

            criminals[0] = new Criminal("Joel", 31);
            criminals[1] = new Criminal("Jesus", 51);
            criminals[2] = new Criminal("John", 26);



            criminals[0].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Ascot", "Murder"));
            criminals[0].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Mall", "Homocide"));
            criminals[0].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Hospital", "Robbery"));


            criminals[1].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "7-11", "Fraud"));
            criminals[1].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Gym", "Assault"));
            criminals[1].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "University", "Abuse of Drugs"));


            criminals[2].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Ikea", "Child Abuse"));
            criminals[2].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Mcdonalds", "Clown Abuse"));
            criminals[2].AddCrime(new Crime(DateTime.Parse("31/1/2021"), "Military Base", "Soldier Abuse"));



            for (int i = 0; i < criminals.Length; i++)
            {
                for (int x = 0; x < criminals[i].CountCrimes(); x++)
                {
                    Console.WriteLine(criminals[i].Getname() + ", " + criminals[i].GetCrime(x));
                }

                Console.WriteLine("");
            }


            //add crimes to all 3 criminals
            //Write a for loop thtat lopps through all 3 criminals
            //Loops through each crime for each criminal and prints out all the information
        }
示例#2
0
        static void Main(string[] args)
        {
            Criminal[] criminals = new Criminal[3];
            criminals[0] = new Criminal("Joel", 31);
            criminals[1] = new Criminal("Jesus", 51);
            criminals[2] = new Criminal("John", 26);

            criminals[0].AddCrime(new Crime(DateTime.Parse("01/01/2020"), "Ascot", "Robbery"));
            criminals[1].AddCrime(new Crime(DateTime.Parse("02/01/2020"), "Ascot", "Jaywalking"));
            criminals[2].AddCrime(new Crime(DateTime.Parse("03/01/2020"), "Ascot", "Abusing"));


            for (int i = 0; i < criminals.Length; i++)
            {
                int TotalCrime = criminals[i].CountCrimes();

                for (int x = 0; x < TotalCrime; x++)
                {
                    Console.WriteLine("NAME:" + criminals[i].GetName() + "   " + "CRIME:" + criminals[i].GetCrime(x).GetAct() + "   " +
                                      "LOCATION:" + criminals[i].GetCrime(x).GetLocation() + "   " + "DATE:" + criminals[i].GetCrime(x).GetDate());
                }
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            Criminal[] criminals = new Criminal[3];
            criminals[0] = new Criminal("Joel", 31);
            criminals[1] = new Criminal("Jesus", 51);
            criminals[2] = new Criminal("John", 26);

            criminals[0].AddCrime(new Crime(DateTime.Parse("1/2/2021"), "Ascot", "Armed Robbery"));

            //=========================================================================

            //hw = add crimes to all 3 criminals
            //     write a for loop below that loops through all 3 criminals and
            //     loops thorugh each crime for each criminal and prints all of the info.

            //extention: if they have max crimes (10), print msg "due for execution"

            criminals[1].AddCrime(new Crime(DateTime.Parse("19/1/2021"), "7-11", "Damaging goods"));
            criminals[2].AddCrime(new Crime(DateTime.Parse("23/1/2021"), "book store", "Arson"));



            for (int i = 0; i < criminals.Length; i++)
            {
                string criminalName = criminals[i].GetName();
                int    criminalAge  = criminals[i].GetAge();
                Console.WriteLine("criminal no. " + i + " " + criminalName + " age:" + criminalAge);


                string   crimeAddress   = criminals[i].GetLocation();
                DateTime crimeDate      = criminals[i].GetDate();
                string   crimeCommitted = criminals[i].GetAct();

                Console.WriteLine("Commited " + crimeCommitted + " at " + crimeAddress + " on the " + crimeDate);
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Criminal[] Criminals = new Criminal[3];
            Criminals[0] = new Criminal("Joel", 31);
            Criminals[1] = new Criminal("Jesus", 51);
            Criminals[2] = new Criminal("John", 26);

            Criminals[0].AddCrime(new Crime(DateTime.Parse("31/01/2020"), "Ascot", "Stealing"));
            Criminals[0].AddCrime(new Crime(DateTime.Parse("30/01/2020"), "Airport", "Stole dog"));

            Criminals[1].AddCrime(new Crime(DateTime.Parse("01/02/2021"), "Ascot", "Talking to Inn"));

            Criminals[2].AddCrime(new Crime(DateTime.Parse("01/02/2021"), "Ascot", "Being Friends with Inn"));


            for (int i = 0; i < Criminals.Length; i += 1)
            {
                int TotalCrime = Criminals[i].CountCrime();
                if (TotalCrime > 1)
                {
                    Console.WriteLine("CRIMINAL: " + (i + 1));
                    Console.WriteLine("EXECUTE");
                }
                else
                {
                    Console.WriteLine("CRIMINAL: " + (i + 1));
                    for (int y = 0; y < TotalCrime; y += 1)
                    {
                        Console.WriteLine("ACT: " + Criminals[i].GetCrime(y).GetAct() + " " + "LOCATION: " + Criminals[i].GetCrime(y).GetLocation());
                    }
                }
            }
            // HW
            // Add Crimes to all 3 Criminals
            // Write a for loop below which loop through all 3 criminals
            // loops through each crime for each criminal and prints all of the information.
            // Extension, if they have more than 10 crimes then show message EXECUTE


            //Criminal Joel = new Criminal("Joel", 31);
            //Ciminal Jesus = new Criminal("Jesus", 51);
            //Criminal John = new Criminal("John", 26);

            //Console.WriteLine(Joel.GetName());

            //DateTime Date;
            //Date = DateTime.Parse("31/01/2021");

            //Crime Crime1 = new Crime(Date, "Ascot", "Armed Robbery");
            //Crime Crime2 = new Crime(Date, "Ascot", "Armed Robbery");
            //Crime Crime3 = new Crime(Date, "Ascot", "Armed Robbery");
            //Crime Crime4 = new Crime(Date, "Not Ascot", "UnArmed Robbery");

            //Console.WriteLine(Joel.AddCrime(Crime1));
            //Console.WriteLine(Joel.AddCrime(Crime2));
            //Console.WriteLine(Joel.AddCrime(Crime3));
            //Console.WriteLine(Joel.AddCrime(Crime4));

            //Console.WriteLine(Joel.GetCrime(0).GetAct());
            //Console.WriteLine(Joel.GetCrime(0).GetLocation());


            //for (int i = 0; i < Joel.CountCrime(); i += 1)
            //{
            //    Console.WriteLine(Joel.GetCrime(i).GetAct() + " " +  Joel.GetCrime(i).GetLocation());
            //}
        }