Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WzorceProjektowe
- {
- // Nie zmieniaj poniższego interfejsu
- public interface IRectangle
- {
- int Area();
- int GetWidth();
- int GetHeight();
- }
- // Nie zmieniaj poniższej klasy
- public class Rectangle : IRectangle
- {
- int Height;
- int Width;
- public Rectangle(int height, int width)
- {
- Height = height;
- Width = width;
- }
- public int Area()
- {
- return Width * Height;
- }
- public int GetHeight()
- {
- return Height;
- }
- public int GetWidth()
- {
- return Width;
- }
- }
- // Nie zmieniaj poniższej klasy
- public class Square
- {
- int Side;
- public Square(int side)
- {
- Side = side;
- }
- public int Area()
- {
- return Side * Side;
- }
- public int GetSide()
- {
- return Side;
- }
- }
- public class SquareToRectangleAdapter
- {
- // TODO
- }
- // Nie zmieniaj poniższej klasy
- public class Program
- {
- static void Main(string[] args)
- {
- Square kwadrat = new Square(4);
- IRectangle adapter = new SquareToRectangleAdapter(kwadrat);
- Console.WriteLine($"Prostokąt o bokach a={adapter.GetHeight()} i b={adapter.GetWidth()} ma pole {adapter.Area()} ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement