Форум Сообщества Аналитиков

×


Как правильно нарисовать диаграмму классов?(Прочитано 24 раз)
Как правильно нарисовать диаграмму классов?


Диаграмма в онлайн редакторе: https://www.plantuml.com/plantuml/uml/VP71IWCn443l-OevjaZx0KMaseC85Znu4m_3PimEpKxAP5PPr7ytYsPT3sikERoyUJ3PPqErleikdrZEgDX1P24RpWH9hKtEDH5pXWTDOQJl3igvW2Eoh513ta4sPGbFp-iTl2RsxhCwnoGqt61pcgnRiWEgVopZL-jgpfYIPxldZct4BFRBhaLwZ8UsDAd2KdBb9dt1Xk3kMny39RYSMuxzdvhFlzpuz2QRQIr_uSSFdHRWwhkjScXjUpL3Un9VVk0B


**Код**
**Program**
```cs
class Program
{
    static void Main(string[] args)
    { 
        ICreditCard creditCard = new MoneyBack();
        Console.WriteLine("CardType : "    + cardDetails.GetCardType());
        Console.WriteLine("CreditLimit : " + cardDetails.GetCreditLimit());
        Console.WriteLine("AnnualCharge :" + cardDetails.GetAnnualCharge());
    }
}
```


**ICreditCard**
```cs
public interface ICreditCard
{
    string GetCardType();
    int GetCreditLimit();
    int GetAnnualCharge();
}

```

**MoneyBack**
```cs
public class MoneyBack : ICreditCard
{
    public string GetCardType()
    {
        return "MoneyBack";
    }
    public int GetCreditLimit()
    {
        return 15000;
    }
    public int GetAnnualCharge()
    {
        return 500;
    }
}
```



Solut-1 --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---



```puml
@startuml
skinparam linetype ortho

class Program {
    + Main(args: string[]): void
}

class MoneyBack {
    + GetCardType(): string
    + GetCreditLimit(): int
    + GetAnnualCharge(): int
}


interface ICreditCard {
  + GetCardType(): string
  + GetCreditLimit(): int
  + GetAnnualCharge(): int
}

ICreditCard <-down- Program
ICreditCard <|-down- MoneyBack
Program .right.> MoneyBack
@enduml
```

Solut-2 --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---


```puml
@startuml
class Program {
    static void Main(string[] args)
}

interface ICreditCard {
    string GetCardType()
    int GetCreditLimit()
    int GetAnnualCharge()
}

class MoneyBack {
    string GetCardType()
    int GetCreditLimit()
    int GetAnnualCharge()
}

Program -right-|> ICreditCard
ICreditCard <|.. MoneyBack
@enduml
```



Solut-3 --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---


```puml
@startuml
left to right direction

class Program {
    static void Main(string[] args)
}

interface ICreditCard {
    string GetCardType()
    int GetCreditLimit()
    int GetAnnualCharge()
}

class MoneyBack {
    string GetCardType()
    int GetCreditLimit()
    int GetAnnualCharge()
}

Program --|> ICreditCard
ICreditCard <|.. MoneyBack
@enduml
```

Solut-4 --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---




 

Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19