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;
- namespace ConsoleApplication2
- {
- class Punkt {
- int x;
- int y;
- public Punkt(int x, int y) {
- this.x = x;
- this.y = y;
- }
- public void Przesuń(int a, int b) {
- this.x += a;
- this.y += b;
- }
- public bool CzyIdentyczny(Punkt p)
- {
- return x == p.x && y == p.y;
- }
- public void Wyświetl() {
- Console.WriteLine("X: "+x+ " Y: "+y);
- }
- }
- class PunktKolorowy : Punkt {
- string kolor;
- public PunktKolorowy(int x, int y, string kolor)
- : base(x, y)
- {
- this.kolor = kolor;
- }
- public new void Wyświetl()
- {
- base.Wyświetl();
- Console.WriteLine("Kolor: "+kolor);
- }
- public bool CzyIdentyczny(PunktKolorowy p)
- {
- return kolor == p.kolor && base.CzyIdentyczny(p);
- }
- }
- class PunktKolorowyOpisowy : PunktKolorowy
- {
- string opis;
- public PunktKolorowyOpisowy(int x, int y, string kolor, string opis) : base(x, y, kolor)
- {
- this.opis = opis;
- }
- public void Wyświetl()
- {
- Console.WriteLine("Opis: " + opis);
- base.Wyświetl();
- }
- }
- class Program
- {
- static void Main(string[] args) {
- Punkt p = new Punkt(3, 4);
- p.Wyświetl();
- p.Przesuń(1, 1);
- p.Wyświetl();
- PunktKolorowy p2 = new PunktKolorowy(1, 2, "czarny");
- p2.Wyświetl();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement