Anthony Ames
3
Q:

c# error CS7036

/*		Sedan.cs(41,5): error CS0200: Property or indexer
		'Sedan.Speed' cannot be assigned to -- it is read only 		*/

public void SpeedUp()
    {
    Speed += 5;
    }					//Trying to change/set value

public double Speed
    { get; }			//Property  speed doesn't have setter
    
public double Speed
    { get; set; }		//Fixes error
    
0
/*
  error CS7036: There is no argument given that corresponds to the
  required formal parameter 'speed' of 'Vehicle.Vehicle(double)' 
    																*/

// Created a Constructor in superclass Vehicle
public Vehicle( double speed )
    {
      Speed = speed;
      LicensePlate = Tools.GenerateLicensePlate();
    }

//Original Constructor
class Sedan
  {
    public Sedan(double speed)
    {
      Speed = speed;
      LicensePlate = Tools.GenerateLicensePlate();
      Wheels = 4;
    }

// Remove 'Speed' and 'LicensePlate' from Sedan Constructor
// Add 'class Sedan : Vehicle '
// Add 'public Sedan(double speed) : base(speed)'
  
//New Constructor
class Sedan : Vehicle
  {
    public Sedan(double speed) : base(speed)
    {
      Wheels = 4;
    }
  }
0

New to Communities?

Join the community