Categories
Visual C#

Constructor Chaining в C#

namespace OOP {
  class GSM {
    private string model;
    private string manufacturer;
    private decimal ? price;
    private string owner;
    private Battery battery;
    private Display display;

    public GSM(): this("Unknown Model", "Unknown Manifacturer") {}

    public GSM(string model, string manifacturer): this(model, manifacturer, null) {}

    public GSM(string model, string manifacturer, decimal ? price): this(model, manifacturer, price, null) {}

    public GSM(string model, string manifacturer, decimal ? price, string owner): this(model, manifacturer, price, owner, null) {}

    public GSM(string model, string manifacturer, decimal ? price, string owner, Battery battery): this(model, manifacturer, price, owner, battery, null) {}

    public GSM(string model, string manifacturer, decimal ? price, string owner, Battery battery, Display display) {
      this.model = model;
      this.manufacturer = manifacturer;
      this.price = price;
      this.owner = owner;
      this.battery = battery;
      this.display = display;
    }
  }
}