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;
- namespace ConsoleApplication1
- {
- public class Program
- {
- public abstract class Student
- {
- protected string imie;
- protected string nazwisko;
- protected int nr_indeksu;
- public Student(string x,string y,int z) //konstruktor
- {
- this.imie = x;
- this.nazwisko = y;
- this.nr_indeksu = z;
- }
- public abstract void Pokaz();
- public abstract void NajlepszaUczelnia();
- }
- public class StudentUniwersytetu : Student
- {
- string uczelnia;
- string specjalnosc;
- public StudentUniwersytetu(string x, string y, int z) : base(x, y, z) //konstruktor SU
- {
- this.uczelnia = "Uniwersytet";
- this.specjalnosc = "Teoria";
- }
- public override void Pokaz() //Polimorfizm przez nadpisanie Pokaz()
- {
- System.Console.WriteLine("->Klasa Student Uniwersytetu: ");
- System.Console.WriteLine("->Imię studenta : " + imie);
- System.Console.WriteLine("->Nazwisko : " + nazwisko);
- System.Console.WriteLine("->Nr indeksu : " + nr_indeksu);
- System.Console.WriteLine("->Specjalnosc : " + specjalnosc);
- }
- public override void NajlepszaUczelnia() //Polimorfizm przez nadpisanie NajlepszaUczelnia()
- {
- System.Console.WriteLine("->Najlepsza uczelnia: " + uczelnia);
- }
- }
- public class StudentPolitechniki : Student
- {
- string uczelnia;
- string specjalnosc;
- public StudentPolitechniki(string x, string y, int z) : base(x, y, z) //konstruktor SP
- {
- this.uczelnia = "Politechnika";
- this.specjalnosc = "Improwizacja";
- }
- public override void Pokaz() //Polimorfizm przez nadpisanie Pokaz()
- {
- System.Console.WriteLine("Klasa Student Politechniki: ");
- System.Console.WriteLine("->Imię studenta : " + imie);
- System.Console.WriteLine("->Nazwisko : " + nazwisko);
- System.Console.WriteLine("->Nr indeksu : " + nr_indeksu);
- System.Console.WriteLine("->Specjalnosc : " + specjalnosc);
- }
- public override void NajlepszaUczelnia() //Polimorfizm przez nadpisanie NajlepszaUczelnia()
- {
- System.Console.WriteLine("->Najlepsza uczelnia: " + uczelnia);
- }
- }
- public static void Main(string[] args)
- {
- // Create an instance of Manager and assign it to a Manager reference:
- StudentPolitechniki m1 = new StudentPolitechniki("H.", "Ackerman ", 133222);
- m1.Pokaz();
- m1.NajlepszaUczelnia();
- System.Console.WriteLine("------------------------------------------------------------");
- StudentUniwersytetu m2 = new StudentUniwersytetu("M.", "Borawski", 111122);
- m2.Pokaz();
- m2.NajlepszaUczelnia();
- // Create an instance of Manager and assign it to an Employee reference:
- /*Employee ee1 = new Manager("M. Knott");
- ee1.Show(); //call the show method of the Manager class*/
- }
- }
- }
- //#######################################################
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public abstract class Student
- {
- public string imie;
- public string nazwisko;
- public int nr_indeksu;
- public Student(string x,string y,int z) //konstruktor
- {
- this.imie = x;
- this.nazwisko = y;
- this.nr_indeksu = z;
- }
- public abstract void Pokaz();
- public abstract void NajlepszaUczelnia();
- }
- public class StudentUniwersytetu : Student
- {
- string uczelnia;
- string specjalnosc;
- public StudentUniwersytetu(string x, string y, int z)
- : base(x, y, z) //konstruktor SU
- {
- this.uczelnia = "Uniwersytet";
- this.specjalnosc = "Teoria";
- }
- public override void Pokaz() //Polimorfizm przez nadpisanie Pokaz()
- {
- System.Console.WriteLine("->Klasa Student Uniwersytetu: ");
- System.Console.WriteLine("->Imię studenta : " + imie);
- System.Console.WriteLine("->Nazwisko : " + nazwisko);
- System.Console.WriteLine("->Nr indeksu : " + nr_indeksu);
- System.Console.WriteLine("->Specjalnosc : " + specjalnosc);
- }
- public override void NajlepszaUczelnia() //Polimorfizm przez nadpisanie NajlepszaUczelnia()
- {
- System.Console.WriteLine("->Najlepsza uczelnia: " + uczelnia);
- }
- }
- public class StudentPolitechniki : Student
- {
- string uczelnia;
- string specjalnosc;
- public StudentPolitechniki(string x, string y, int z)
- : base(x, y, z) //konstruktor SP
- {
- this.uczelnia = "Politechnika";
- this.specjalnosc = "Improwizacja";
- }
- public override void Pokaz() //Polimorfizm przez nadpisanie Pokaz()
- {
- System.Console.WriteLine("Klasa Student Politechniki: ");
- System.Console.WriteLine("->Imię studenta : " + imie);
- System.Console.WriteLine("->Nazwisko : " + nazwisko);
- System.Console.WriteLine("->Nr indeksu : " + nr_indeksu);
- System.Console.WriteLine("->Specjalnosc : " + specjalnosc);
- }
- public override void NajlepszaUczelnia() //Polimorfizm przez nadpisanie NajlepszaUczelnia()
- {
- System.Console.WriteLine("->Najlepsza uczelnia: " + uczelnia);
- }
- }
- System.Collections.Generic.List<Student> studenci = new System.Collections.Generic.List<Student>();
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- string imi = textBox1.Text;
- string nazw = textBox2.Text;
- string indeks = textBox3.Text;
- int indek = Int32.Parse(indeks);
- if (radioButton1.Checked)
- {
- studenci.Add(new StudentPolitechniki(imi, nazw, indek));
- }
- else if (radioButton2.Checked)
- {
- studenci.Add(new StudentUniwersytetu(imi, nazw, indek));
- }
- }
- private void textBox3_TextChanged(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- foreach (Student s in studenci)
- {
- MessageBox.Show("Klasa Student Politechniki: ->Imię studenta : " + s.imie + "->Nazwisko : " + s.nazwisko + "->Nr indeksu : " + s.nr_indeksu);
- }
- /*foreach (StudentUniwersytetu s in studenci)
- {
- MessageBox.Show("Klasa Student Politechniki: ->Imię studenta : " + s.imie + "->Nazwisko : " + s.nazwisko + "->Nr indeksu : " + s.nr_indeksu);
- }*/
- }
- private void textBox1_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox2_TextChanged(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement