Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Mihui_CSharp
- {
- class Program
- {
- static void Main(string[] args){
- Rectangle patrat = new Square(5);
- Rectangle dreptunghi = new Rectangle(5, 10);
- Console.WriteLine(patrat) // Este un patrat de latura l
- Console.WriteLine(dreptunghi) // Este un drepthunghi de laturi l1 si l2
- Rectangle r1 = new Rectangle(6, 7);
- Rectangle r2 = new Rectangle(7, 4);
- if (r1 > r2)
- Console.WriteLine("R1 are aria mai mare");
- else
- Console.WriteLine("R2 are aria mai mare");
- Rectangle r3 = new Rectangle(8);
- Console.Write("R3 are aria: ");
- Console.WriteLine(r3.GetArea());
- List<Shape> container = new List<Shape>()
- {
- r1,
- r2,
- r3,
- new Square(8),
- new Rectangle(5, 3)
- new Circle(5)
- };
- double totalArea = 0;
- foreach (Shape shape in container)
- {
- Console.WriteLine(shape); // Este un <Shape> cu ...
- totalArea += shape.GetArea();
- }
- Console.Write("Aria totala este: ");
- Console.WriteLine(totalArea);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement