title: Vehicle Object Array - C#
body: <p>I'm having trouble writing up some code. I'm not too sure where and how to write up the constructors and the accessors.</p>
  
  <h2>The activity I have to do is this:</h2>
  
  <p>Write 3 derived classes to allow a user to enter the details of three types of Vehicles with their attributes.</p>
  
  <p>• Car (make, model, year, bodyType)</p>
  
  <p>• Airplane (make, model, year, noEngines, engineType)</p>
  
  <p>• Boat (make, model, year, length, hullType)</p>
  
  <p>The 4th class is the base class Vehicle which contains the shared attributes and methods</p>
  
  <p>Make all attributes either private (in derived classes) or protected (in base class) and write accessor methods for each attribute.</p>
  
  <p>Write 2 constructors for each derived class. One with no arguments and the other which accepts the values of the attributes in the derived class as arguments.</p>
  
  <p>Write a Console Application called Fleet.cs which creates and displays 2 of each Vehicle type</p>
  
  <h2>My code so far is as follows:</h2>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace ConsoleApplication5
  {
      class Vehicle
      {
          static void Main(string[] args)
          {
          }
  
          class Car
          {
              protected string make
              {
                  get
                  {
                      return make;
                  }
                  set
                  {
                      make = value;
                  }
              }
  
              protected string model
              {
                  get
                  {
                      return model;
                  }
                  set
                  {
                      model = value;
                  }
              }
  
              protected int year
              {
                  get
                  {
                      return year;
                  }
                  set
                  {
                      year = value;
                  }
              }
  
              protected string bodyType
              {
                  get
                  {
                      return bodyType;
                  }
                  set
                  {
                      bodyType = value;
                  }
              }
  
              public bool isInitialized;
              public Car()
              {
                  isInitialized = true;
              }
          }
      }
  
      class Airplane
      {
          protected string make
          {
              get
              {
                  return make;
              }
              set
              {
                  make = value;
              }
          }
  
          protected string model
          {
              get
              {
                  return model;
              }
              set
              {
                  model = value;
              }
          }
  
          protected int year
          {
              get
              {
                  return year;
              }
              set
              {
                  year = value;
              }
          }
  
          protected int numEngines
          {
              get
              {
                  return numEngines;
              }
              set
              {
                  numEngines = value;
              }
          }
  
          protected int engineType
          {
              get
              {
                  return engineType;
              }
              set
              {
                  engineType = value;
              }
          }
      }
  
      class Boat
      {
          protected string make
          {
              get
              {
                  return make;
              }
              set
              {
                  make = value;
              }
          }
  
          protected string model
          {
              get
              {
                  return model;
              }
              set
              {
                  model = value;
              }
          }
  
          protected string year
          {
              get
              {
                  return year;
              }
              set
              {
                  year = value;
              }
          }
  
          protected string length
          {
              get
              {
                  return length;
              }
              set
              {
                  length = value;
              }
          }
  
          protected string hullType
          {
              get
              {
                  return hullType;
              }
              set
              {
                  hullType = value;
              }
          }
      }
  }
  </code></pre>