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 HomeW
- {
- abstract class Figure
- {
- protected double area = 0;
- public virtual void drawFigure()
- {
- Console.WriteLine("Figura nie moze byc narysowana");
- }
- public abstract double getArea();
- public virtual void setArea(double area)
- {
- this.area = area;
- }
- }
- class Rectangle : Figure
- {
- int x = 0;
- int y = 0;
- public Rectangle(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public override void drawFigure()
- {
- for (int a = 0; a < x; ++a)
- {
- for (int b = 0; b < y; ++b)
- {
- Console.Write("#");
- }
- Console.WriteLine();
- }
- }
- public override double getArea()
- {
- base.setArea(x *y);
- return area;
- }
- }
- class Triangle : Figure
- {
- int h;
- int w;
- public Triangle(int h, int w)
- {
- this.h = h;
- this.w = w;
- }
- public override double getArea()
- {
- return 0.5*h*w;
- }
- public override void drawFigure()
- {
- for(int a=1; a<= h; ++a)
- {
- for(int b=0; b<a; ++b)
- {
- Console.Write("#");
- }
- Console.WriteLine();
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement