Advertisement
Guest User

Untitled

a guest
Apr 29th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using System.Xml;
  8. using System.Xml.Serialization;
  9. using System.Runtime.Serialization.Formatters.Binary;
  10. namespace ConsoleApp6
  11. {
  12. class Program
  13. {
  14. static void Main(string[] args)
  15. {
  16. Promo a = new Promo();
  17. a.Menu();
  18. }
  19. }
  20. class Promo
  21. {
  22. public void Menu()
  23. {
  24. Console.WriteLine("1. Dodaj nową klasę");
  25. Console.WriteLine("2. Edytuj kasę");
  26. Console.WriteLine("3. Usun klase");
  27. Console.WriteLine("Esc. Wyjdz z programu");
  28. wybormenu();
  29. }
  30. public void wybormenu()
  31. {
  32. ConsoleKeyInfo klawisz = Console.ReadKey();
  33. switch(klawisz.Key)
  34. {
  35. case ConsoleKey.D1:
  36. Console.Clear();
  37. Dodaj();
  38. Menu();
  39. break;
  40. case ConsoleKey.D2:
  41. Console.Clear();
  42.  
  43. break;
  44. case ConsoleKey.D3:
  45. Console.Clear();
  46.  
  47. break;
  48.  
  49. }
  50. }
  51. public void Dodaj()
  52. {
  53.  
  54. Console.WriteLine("Aktualnie mozesz dodac nowa klase");
  55. string imie;
  56. string nazwisko;
  57. string nr_kl;
  58. int ocena_polski;
  59. int ocena_historia;
  60. Console.WriteLine("Podaj ileś uczniow w klasie ");
  61. int liczba_uczniow = Convert.ToInt32(Console.ReadLine());
  62. for (int n = 0; n <= liczba_uczniow; n++)
  63. {
  64. List<Dane> dane = new List<Dane>();
  65. Console.Clear();
  66. Console.WriteLine("Podaj numer klasy");
  67. nr_kl = Console.ReadLine();
  68. Console.WriteLine("Podaj imie ucznia");
  69. imie = Console.ReadLine();
  70. Console.WriteLine("Podaj imie nazwisko");
  71. nazwisko = Console.ReadLine();
  72. Console.WriteLine("Podaj ocene z polskiego");
  73. ocena_polski = Convert.ToInt32(Console.ReadLine());
  74. Console.WriteLine("Podaj ocene z historii");
  75. ocena_historia = Convert.ToInt32(Console.ReadLine());
  76. // wypełnienie tablicy struktur
  77. dane.Add(new Dane(imie, nazwisko, nr_kl, ocena_polski, ocena_historia));
  78. Console.WriteLine("Nacisnij enter aby dodać kolejnego ucznia");
  79. Console.ReadLine();
  80. Console.Clear();
  81. XmlSerializer ser = new XmlSerializer(typeof(List<Dane>));
  82. TextWriter tw = new StreamWriter("plik.txt");
  83. ser.Serialize(tw, dane);
  84. tw.Close();
  85.  
  86. }
  87.  
  88. }
  89. }
  90. public class Dane
  91. {
  92. string imieucz;
  93. string nazwiskoucz;
  94. string nr_klasy;
  95. int ocen_polski;
  96. int ocen_historia;
  97. public string Imieucz { get { return imieucz; } set { imieucz = value; } }
  98. public string Nazwiskoucz { get { return nazwiskoucz; } set { nazwiskoucz = value; } }
  99. public string Nr_klasy { get { return nr_klasy; } set { nr_klasy = value; } }
  100. public int Ocen_polski { get { return ocen_polski; } set { ocen_polski = value; } }
  101. public int Ocen_historia { get { return ocen_historia; } set { ocen_historia = value; } }
  102. public Dane(string simieucz, string snazwiskoucz, string snr_klasy, int nocen_polski,int nocen_historia)
  103. {
  104. imieucz = simieucz;
  105. nazwiskoucz = snazwiskoucz;
  106. nr_klasy = snr_klasy;
  107. ocen_polski = nocen_polski;
  108. ocen_historia = nocen_historia;
  109. }
  110. public Dane() { }
  111. }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement