jeudi 24 novembre 2016

How to Design a shedManager

I try to design a shed car with design patterns.

My shed contain abstract class car:

public abstract class Vehicle {
      public string Name { get; set; }
      public Color Color { get; set; }

      public void ChangeColor(Color color)
    {
        Color = color;
    }
    public void ChangeName(string name)
      {
        Name= name;
      }
 }

I create a ShedManager based on singlethon pattern.

ShedManager contain List of Vehicle The ShedManager Use Factory pattern to create appropiate instance of Vehicle.

The operation i want to support:

Draw Vehicle blue;

Darw Vehicle green;

Chnage Name;

so, i create a menu item at Console.Main and by Switch case i call relevant function at Vehicle object.

So, there is two cases for change color so each them sent with relevant color.

I try to think how can i implement this so if in the future i will add another option (like change color to black) i can to do without code change.

I iterate over design pattern and no one visible to be appropriate..

So, you think its possible or the current design is good enough?

Aucun commentaire:

Enregistrer un commentaire