Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Xml;
- using System.Xml.Serialization;
- using System.Runtime.Serialization.Formatters.Binary;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- Promo a = new Promo();
- a.Menu();
- }
- }
- class Promo
- {
- public void Menu()
- {
- Console.WriteLine("1. Dodaj nową klasę");
- Console.WriteLine("2. Edytuj kasę");
- Console.WriteLine("3. Usun klase");
- Console.WriteLine("Esc. Wyjdz z programu");
- wybormenu();
- }
- public void wybormenu()
- {
- ConsoleKeyInfo klawisz = Console.ReadKey();
- switch(klawisz.Key)
- {
- case ConsoleKey.D1:
- Console.Clear();
- Dodaj();
- Menu();
- break;
- case ConsoleKey.D2:
- Console.Clear();
- break;
- case ConsoleKey.D3:
- Console.Clear();
- break;
- }
- }
- public void Dodaj()
- {
- Console.WriteLine("Aktualnie mozesz dodac nowa klase");
- string imie;
- string nazwisko;
- string nr_kl;
- int ocena_polski;
- int ocena_historia;
- Console.WriteLine("Podaj ileś uczniow w klasie ");
- int liczba_uczniow = Convert.ToInt32(Console.ReadLine());
- for (int n = 0; n <= liczba_uczniow; n++)
- {
- List<Dane> dane = new List<Dane>();
- Console.Clear();
- Console.WriteLine("Podaj numer klasy");
- nr_kl = Console.ReadLine();
- Console.WriteLine("Podaj imie ucznia");
- imie = Console.ReadLine();
- Console.WriteLine("Podaj imie nazwisko");
- nazwisko = Console.ReadLine();
- Console.WriteLine("Podaj ocene z polskiego");
- ocena_polski = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Podaj ocene z historii");
- ocena_historia = Convert.ToInt32(Console.ReadLine());
- // wypełnienie tablicy struktur
- dane.Add(new Dane(imie, nazwisko, nr_kl, ocena_polski, ocena_historia));
- Console.WriteLine("Nacisnij enter aby dodać kolejnego ucznia");
- Console.ReadLine();
- Console.Clear();
- XmlSerializer ser = new XmlSerializer(typeof(List<Dane>));
- TextWriter tw = new StreamWriter("plik.txt");
- ser.Serialize(tw, dane);
- tw.Close();
- }
- }
- }
- public class Dane
- {
- string imieucz;
- string nazwiskoucz;
- string nr_klasy;
- int ocen_polski;
- int ocen_historia;
- public string Imieucz { get { return imieucz; } set { imieucz = value; } }
- public string Nazwiskoucz { get { return nazwiskoucz; } set { nazwiskoucz = value; } }
- public string Nr_klasy { get { return nr_klasy; } set { nr_klasy = value; } }
- public int Ocen_polski { get { return ocen_polski; } set { ocen_polski = value; } }
- public int Ocen_historia { get { return ocen_historia; } set { ocen_historia = value; } }
- public Dane(string simieucz, string snazwiskoucz, string snr_klasy, int nocen_polski,int nocen_historia)
- {
- imieucz = simieucz;
- nazwiskoucz = snazwiskoucz;
- nr_klasy = snr_klasy;
- ocen_polski = nocen_polski;
- ocen_historia = nocen_historia;
- }
- public Dane() { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement