Пожалуйста, проверьте, соответствует ли мой код этим требованиям. Это CRM-система.
Data Customer Information • Forename • Surname • Date of Birth Vehicle Information • Manufacturer • Model • Registration number • Registration date • Engine size (in cc) • Owner • InteriorColour (Car only) • Has Helmet Storage (Motorcycle only) Required Relationships • Customers can have 1 to many vehicles. • Vehicle must have exactly one owner. • Vehicle type cannot be changed once it is created. Reports • We will require reports to be designed to contain: o All known customers and any vehicles they own. o All customers between the age of 20 and 30. o All Vehicles registered before 1st January 2010. o All Vehicles with an engine size over 1100. Expected demonstrable skills • Good understanding of C#. • Good understanding of Object Orientated (OO) principles. • Good understanding of relational data principles. • Reusable code – low coupling, high cohesion
Что я уже пробовал:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Graduate_Test_Brief { class Program { static void Main(string[] args) { string sChoice; int iChoice; do { Console.WriteLine("WELCOME TO CRM..."); Console.WriteLine("PLEASE CHOOSE A OPTION FROM BELOW:"); Console.WriteLine("1. REPORT FOR ALL KNOWN CUSTOMERS AND ANY VEHICLES THEY OWN."); Console.WriteLine("2. REPORT FOR ALL CUSTOMERS BETWEEN THE AGE OF 20 AND 30."); Console.WriteLine("3. REPORT FOR ALL VEHICLES REGISTERED BEFORE 1ST JANUARY 2010."); Console.WriteLine("4. REPORT FOR ALL VEHICLES WITH AN ENGINE SIZE OVER 1100."); Console.Write("PLEASE ENTER YOUR CHOICE HERE: "); sChoice = Console.ReadLine(); iChoice = Convert.ToInt32(sChoice); switch (iChoice) { case 1: Report1(@"..\..\Assets\Customer Information.csv"); break; case 2: Report2(20, 30, @"..\..\Assets\Customer Information.csv", 3); break; case 3: Report3(2010, @"..\..\Assets\Customer Information.csv", 9); break; case 4: Report4(1100, @"..\..\Assets\Customer Information.csv", 8); break; default: Console.Read(); break; } } while (true); } public static void Report1(string filePath) { string[] reportNotFound = { "Report Not Found" }; List<string[]> list1 = new List<string[]>(); try { string[] lines = File.ReadAllLines(filePath); for (int i = 1; i <= lines.Length; i++) { string[] fields = lines[i].Split(','); // string vs = fields[coloumn]; // int vs1 = Int32.Parse(vs); //if (vs1 >= data1) //{ list1.Add(fields); //} } // return list1; } catch (Exception e) { foreach (var list in list1) { for (int i = 0; i < list.Length; i++) { Console.Write(" "+list[i]); } Console.WriteLine(); } } } private static void Report2(int minAge, int maxAge, string filePath, int coloumn) { string[] reportNotFound = { "Report Not Found" }; List<string[]> list1 = new List<string[]>(); try { string[] lines = File.ReadAllLines(filePath); for (int i = 1; i <= lines.Length; i++) { string[] fields = lines[i].Split(','); string vs = fields[coloumn]; DateTime birthDate = DateTime.Parse(vs); DateTime currentDate = DateTime.Now; int age = currentDate.Year - birthDate.Year; if (birthDate > currentDate.AddYears(-age)) { age--; } if (age > minAge && age < maxAge) { list1.Add(fields); } } // return list1; } catch (Exception e) { foreach (var list in list1) { for (int i = 0; i < 1; i++) { Console.Write(list[0] + " " + list[1] + " " + list[2]); } Console.WriteLine(); } } } private static void Report3(int Year, string filePath, int coloumn) { string[] reportNotFound = { "Report Not Found" }; List<string[]> list1 = new List<string[]>(); try { string[] lines = File.ReadAllLines(filePath); for (int i = 1; i <= lines.Length; i++) { string[] fields = lines[i].Split(','); string vs = fields[coloumn]; DateTime regDate = DateTime.Parse(vs); //int regYear = Convert.ToInt32(regDate.Year); if (regDate.Year < Year) { list1.Add(fields); } } // return list1; } catch (Exception e) { foreach (var list in list1) { for (int i = 0; i < 1; i++) { Console.Write(list[4] + " " + list[5] + " " + list[6] + " " + list[7] + " " + list[8] + " " + list[9] + " " + list[10] + " " + list[11] + " " + list[12]); } Console.WriteLine(); } } } private static void Report4(int engSize, string filePath, int coloumn) { string[] reportNotFound = { "Report Not Found" }; List<string[]> list1 = new List<string[]>(); try { string[] lines = File.ReadAllLines(filePath); for (int i = 1; i <= lines.Length; i++) { string[] fields = lines[i].Split(','); string vs = fields[coloumn]; int engineSize = Int32.Parse(vs); //int regYear = Convert.ToInt32(regDate.Year); if (engineSize > engSize) { list1.Add(fields); } } // return list1; } catch (Exception e) { foreach (var list in list1) { for (int i = 0; i < 1; i++) { Console.Write(list[4] + " " + list[5] + " " + list[6] + " " + list[7] + " " + list[8] + " " + list[9] + " " + list[10] + " " + list[11] + " " + list[12]); } Console.WriteLine(); } } } } }