Friday, December 26, 2014

Class-Diagrams

using System;

struct Point
{
    public int X { get; set; }
    public int Y { get; set; }

    public Point(int x, int y) : this()
    {
        this.X = x;
        this.Y = y;
    }
}

using System;

abstract class Shape
{
    protected Point Position { get; set; }

    public Shape(Point position)
    {
        this.Position = position;
    }
}


using System;

struct Color
{
    public byte RedValue { get; set; }
    public byte GreenValue { get; set; }
    public byte BlueValue { get; set; }

    public Color(byte redValue, byte greenValue, byte blueValue)
        : this()
    {
        this.RedValue = redValue;
        this.GreenValue = greenValue;
        this.BlueValue = blueValue;
    }
}




using System;

interface ISufraceCalculatable
{
    float CalculateSurface();
}




using System;

class Square : Shape, ISufraceCalculatable
{
    private float Size { get; set; }

    public Square(float size, int x, int y)
        : base (new Point(x,y))
    {
        this.Size = size;
    }

    public float CalculateSurface()
    {
        return this.Size * this.Size;
    }
}



using System;

class Rectangle : Shape, ISufraceCalculatable
{
    private float Width { get; set; }
    private float Height { get; set; }

    public Rectangle(float width, float height, int x, int y)
        : base (new Point(x,y))
    {
        this.Width = width;
        this.Height = height;
    }

    public float CalculateSurface()
    {
        return this.Width * this.Height;
    }
}


using System;

class FilledSquare : Square
{
    private Color Color { get; set; }

    public FilledSquare(float size, int x, int y, Color color)
        : base(size, x, y)
    {
        this.Color = color;
    }
}





No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...