Filip13

priprema_za_test - ntp

Oct 16th, 2024 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.73 KB | Source Code | 0 0
  1. namespace priprema_za_test
  2. {
  3.     internal class Program
  4.     {
  5.         enum Genre
  6.         {
  7.             EPSKA_FANTASTIKA,
  8.             NAUCNA_FANTASTIKA,
  9.             KOMEDIJA,
  10.             TRAGEDIJA,
  11.             TRILER,
  12.             ROMANSA,
  13.             DETEKTIVSKI
  14.         }
  15.  
  16.         class Book
  17.         {
  18.             public string name;
  19.             public string authorName;
  20.             public int yearRealese;
  21.  
  22.             Genre genre;
  23.  
  24.             public Book(string name, string author, int year, Genre g)
  25.             {
  26.                 this.name = name;
  27.                 this.authorName = author;
  28.                 this.yearRealese = year;
  29.                 this.genre = g;
  30.             }
  31.         }
  32.  
  33.         static void Main(string[] args)
  34.         {
  35.             Book[] books = new Book[100];
  36.  
  37.             int index = 0;
  38.  
  39.             while (true)
  40.             {
  41.                 Console.WriteLine("komande");
  42.                 Console.WriteLine("****************");
  43.                 Console.WriteLine("0 - kraj");
  44.                 Console.WriteLine("1 - unos nove knjige");
  45.                 Console.WriteLine("2 - ispis knjiga sortiranih po autoru");
  46.                 Console.WriteLine("2 - ispis knjiga sortiranih po godini");
  47.  
  48.                 Console.Write("unei komandu: ");
  49.                 string command = Console.ReadLine();
  50.  
  51.                 if (command.Equals(1))
  52.                 {
  53.                     Console.Write("ime: ");
  54.                     string name = Console.ReadLine();
  55.  
  56.                     Console.Write("ime autora: ");
  57.                     string nameAuthor = Console.ReadLine();
  58.  
  59.                     Console.Write("godina izlaska: ");
  60.                     int year = int.Parse(Console.ReadLine());
  61.  
  62.                     Console.Write("zanr: ");
  63.                     string genre = Console.ReadLine();
  64.  
  65.  
  66.                     Genre g = Genre.ROMANSA;
  67.                     switch (genre)
  68.                     {
  69.                         case "EPSKA_FANTASTIKA":
  70.                             g = Genre.EPSKA_FANTASTIKA;
  71.                             break;
  72.                         case "NAUCNA_FANTASTIKA":
  73.                             g = Genre.NAUCNA_FANTASTIKA;
  74.                             break;
  75.                         case "KOMEDIJA":
  76.                             g = Genre.KOMEDIJA;
  77.                             break;
  78.                         case "TRAGEDIJA":
  79.                             g = Genre.TRAGEDIJA;
  80.                             break;
  81.                         case "TRILER":
  82.                             g = Genre.TRILER;
  83.                             break;
  84.                         case "ROMANSA":
  85.                             g = Genre.ROMANSA;
  86.                             break;
  87.                         case "DETEKTIVSKI":
  88.                             g = Genre.DETEKTIVSKI;
  89.                             break;
  90.                     }
  91.  
  92.                     books[index++] = new Book(name, nameAuthor, year, g);
  93.                 }
  94.                 else if (command.Equals(2))
  95.                 {
  96.                     BubbleSort(books);
  97.                 }
  98.                 else if (command.Equals(3))
  99.                 {
  100.  
  101.                 }
  102.                 else if (command.Equals(0))
  103.                 {
  104.                     Console.WriteLine("kraj");
  105.                     break;
  106.                 }
  107.                 else
  108.                 {
  109.  
  110.                 }
  111.  
  112.  
  113.             }
  114.  
  115.         }
  116.  
  117.         private static void BubbleSort(Book[] books)
  118.         {
  119.             for (int i = 0; i < books.Length; i++)
  120.             {
  121.                 for (int j = i + 1; j < books.Length; j++)
  122.                 {
  123.                     if (string.Compare(books[i]., books[i+1]))
  124.                 }
  125.             }
  126.  
  127.  
  128.         }
  129.  
  130.  
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment