private static void Test() { ManagerMasini.addMasina(new Masina("Popescu;Ionescu;Ford;Mondeo;2008;rosu;16.02.2019;6500;" + (string)(Optiuni.ABS + ", " + Optiuni.Airbaguri_laterale + " , " + Optiuni.ConectivitateBluetooth + " , " + Optiuni.CruiseControl + " , " + Optiuni.ProiectoareCeata))); }
public static void cautare() { int nr; int[] masini; Masina masinaC; Console.WriteLine("Cautati dupa: "); Console.WriteLine(" \t a. Nume cumparator"); Console.WriteLine(" \t b. Nume vanzator"); Console.WriteLine(" \t c. Firma"); Console.WriteLine(" \t d. Model"); Console.WriteLine(" \t e. An fabricatie"); Console.WriteLine(" \t f. Culoare"); Console.WriteLine(" \t g. Data tranzactiei"); Console.WriteLine(" \t h. Pret"); Console.WriteLine(); Console.WriteLine("Alegeti o optiune..."); string optiune; switch (Convert.ToChar(optiune = (Console.ReadLine()))) { case 'a': nr = 0; Console.WriteLine("Cautare dupa nume cumparator... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'b': nr = 1; Console.WriteLine("Cautare dupa nume vanzator... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'c': nr = 2; Console.WriteLine("Cautare dupa firma... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'd': nr = 3; Console.WriteLine("Cautare dupa model... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'e': nr = 4; Console.WriteLine("Cautare dupa an fabricatie... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'f': nr = 5; Console.WriteLine("Cautare dupa culoare... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'g': nr = 6; Console.WriteLine("Cautare dupa data tranzactie... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; case 'h': nr = 7; Console.WriteLine("Cautare dupa pret... "); masini = ManagerMasini.cautare(nr); for (int i = 0; i < 1; i++) { masinaC = ManagerMasini.getMasina(masini[i]); //Console.WriteLine(masinaC.toString()); } Console.ReadLine(); break; default: nr = 10; masini = ManagerMasini.cautare(nr); Console.ReadLine(); break; } }
static void Main(string[] args) { ManagerMasini masiniMan; Masina masina; AdministrareMasiniText masTxt; Masina[] masini; IStocareData adminMasini = ManagerMasini.GetAdministratorStocare(); int nrMasini; masini = adminMasini.GetMasina(out nrMasini); Masina.idMasinaProp = nrMasini; for (int i = 0; i < nrMasini; i++) { ManagerMasini.addMasina(masini[i]); } string c; Test(); do { Console.Clear(); Console.WriteLine("1. Adaugare masina"); Console.WriteLine("2. Editare masina"); Console.WriteLine("3. Stergere masina"); Console.WriteLine("4. Cea mai cautata masina"); Console.WriteLine("5. Grafic al preturilor"); Console.WriteLine("6. Tranzactii"); Console.WriteLine("7. Afisare lista masini"); Console.WriteLine("8. Cautare masina"); Console.WriteLine("9. Exit"); switch (Convert.ToChar(c = (Console.ReadLine()))) { case '1': Console.WriteLine("ADAUGARE MASINA"); Console.WriteLine(); Console.Write("Introduceti numele complet al vanzatorului: "); string numev = Console.ReadLine(); Console.Write("Introduceti numele complet al cumparatorului: "); string numec = Console.ReadLine(); Console.Write("Introduceti firma masinii: "); string numef = Console.ReadLine(); Console.Write("Introduceti modelul masinii: "); string numem = Console.ReadLine(); Console.Write("Introduceti anul fabricatiei: "); int anf = Convert.ToInt32(Console.ReadLine()); Console.Write("Introduceti culoarea masinii: "); string culoare = Console.ReadLine(); Console.Write("Introduceti optiunile masinii, separate printr-o virgula: "); string optiuni = Console.ReadLine(); Console.Write("Introduceti data tranzactiei [dd.mm.aaaa]: "); string datat = Console.ReadLine(); Console.Write("Introduceti pretul masinii: "); double pret = Convert.ToDouble(Console.ReadLine()); //masina = new Masina(numev, numec, numef, numem, anf, culoare, optiuni, datat, pret); ManagerMasini.addMasina(new Masina(numev, numec, numef, numem, anf, culoare, optiuni, datat, pret)); Console.ReadLine(); break; case '2': Console.WriteLine("2. EDITARE MASINA"); Console.WriteLine("Lista disponibila cu masini este: \n"); ManagerMasini.getMasini(); Console.WriteLine(); Console.WriteLine("Introduceti ID-ul masinii pe care doriti sa o editati"); int idEdit = Convert.ToInt32(Console.ReadLine()); masina = ManagerMasini.getMasina(idEdit); Console.WriteLine(); Console.WriteLine(" \t a. Nume cumparator"); Console.WriteLine(" \t b. Nume vanzator"); Console.WriteLine(" \t c. Firma"); Console.WriteLine(" \t d. Model"); Console.WriteLine(" \t e. An fabricatie"); Console.WriteLine(" \t f. Culoare"); Console.WriteLine(" \t g. Optiuni"); Console.WriteLine(" \t h. Data tranzactiei"); Console.WriteLine(" \t i. Pret"); Console.WriteLine(); alegeOptiuni(masina); Console.ReadLine(); break; case '3': Console.WriteLine("STERGERE MASINA \n"); Console.WriteLine("Lista disponibila cu masini este: \n"); ManagerMasini.getMasini(); Console.Write("\n Introduceti ID-ul masinii pe care doriti sa o stergeti: "); int id = Convert.ToInt32(Console.ReadLine()); ManagerMasini.removeMasina(id); Console.ReadLine(); break; case '4': Console.WriteLine("CEA MAI CAUTATA MASINA"); Console.WriteLine("Cea mai cautata masina este: "); int idMax = ManagerMasini.numarCautariMax(); Console.WriteLine(ManagerMasini.getMasina(idMax).toString()); Console.ReadLine(); break; case '5': Console.WriteLine("GRAFIC AL PRETURILOR"); ManagerMasini.getMasini(); Console.WriteLine(); Console.Write("Doriti sa ordonati lista in ordine crescatoare sau descrescatoare? [crescator / descrescator]"); int nr; int[] idL; string optiuneCr = Console.ReadLine(); if (optiuneCr.Equals("crescator")) { nr = 0; idL = ManagerMasini.getListaPreturi(nr); for (int i = 0; i < Masina.idM; i++) { Console.WriteLine(ManagerMasini.getMasina(idL[i])); } } else if (optiuneCr.Equals("descrescator")) { nr = 1; idL = ManagerMasini.getListaPreturi(nr); for (int i = 0; i < Masina.idM; i++) { Console.WriteLine(ManagerMasini.getMasina(idL[i])); } } Console.ReadLine(); break; case '6': Console.WriteLine("Optiunea 6"); Console.ReadLine(); break; case '7': Console.WriteLine("Lista masini: "); ManagerMasini.getMasini(); Console.WriteLine(); Console.WriteLine("Doriti sa vedeti optiunile pentru o masina? [y/n]"); string opt = Console.ReadLine(); if (opt.Equals("y")) { Console.WriteLine("Introduceti ID-ul masinii careia doriti sa ii vizionati optiunile... "); int idOpt = Convert.ToInt32(Console.ReadLine()); Masina masOpt = ManagerMasini.getMasina(idOpt); Console.WriteLine("Optiunile masinii sunt: "); for (int i = 0; i < masOpt.getOptiuni().Length; i++) { Console.WriteLine("\t" + masOpt.getOptiuni().GetValue(i)); } } Console.ReadLine(); break; case '8': cautare(); Console.ReadLine(); break; case '9': return; default: Console.WriteLine("Optiune invalida"); Console.ReadLine(); break; } } while (true); }