Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Mihui_CSharp
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args){
  9.             Rectangle patrat     = new Square(5);
  10.             Rectangle dreptunghi = new Rectangle(5, 10);
  11.  
  12.             Console.WriteLine(patrat) // Este un patrat de latura l
  13.             Console.WriteLine(dreptunghi) // Este un drepthunghi de laturi l1 si l2
  14.  
  15.             Rectangle r1 = new Rectangle(6, 7);
  16.             Rectangle r2 = new Rectangle(7, 4);
  17.  
  18.             if (r1 > r2)
  19.                 Console.WriteLine("R1 are aria mai mare");
  20.             else
  21.                 Console.WriteLine("R2 are aria mai mare");
  22.  
  23.             Rectangle r3 = new Rectangle(8);
  24.             Console.Write("R3 are aria: ");
  25.             Console.WriteLine(r3.GetArea());
  26.  
  27.             List<Shape> container = new List<Shape>()
  28.             {
  29.                 r1,
  30.                 r2,
  31.                 r3,
  32.                 new Square(8),
  33.                 new Rectangle(5, 3)
  34.                 new Circle(5)
  35.             };
  36.  
  37.             double totalArea = 0;
  38.             foreach (Shape shape in container)
  39.             {
  40.                 Console.WriteLine(shape); // Este un <Shape> cu ...
  41.                 totalArea += shape.GetArea();
  42.             }
  43.  
  44.             Console.Write("Aria totala este: ");
  45.             Console.WriteLine(totalArea);
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement