Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _2._6
- {
- class Figury
- {
- public virtual void Pole()
- {
- Console.Write("Pole wynosi: ");
- }
- public int a, b, r, h;
- }
- class Kwadrat : Figury
- {
- public override void Pole()
- {
- Console.WriteLine("Pole kwadratu wynosi: {0}",Math.Pow(base.a, 2));
- }
- }
- class Prostokat : Figury
- {
- public override void Pole()
- {
- Console.WriteLine("Pole prostokątu wynosi: {0}", base.a*base.b);
- }
- }
- class Kolo : Figury
- {
- public override void Pole()
- {
- Console.WriteLine("Pole koła wynosi: {0}", Math.Pow(base.a, 2));
- }
- }
- class Trojkat: Figury
- {
- public override void Pole()
- {
- Console.WriteLine("Pole kwadratu wynosi: {0}", base.a*base.h/2);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Figury kw = new Kwadrat();
- kw.a = 2;
- kw.b = 3;
- kw.Pole();
- Figury pr = new Prostokat();
- pr.a = 3;
- pr.b = 3;
- pr.Pole();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement