Question: Using C# and including comments to explain implementation: Create a console app project named Inheritance in a solution named allmine. Replace the main method by

Using C# and including comments to explain implementation:

Create a console app project named Inheritance in a solution named allmine. Replace the main method by the code here (code below). This code provides a main method and also two other methods used by main. Also, at the end, there is a class definition of the class Measurement

Add the code for a new class named Scaled which extends class Measurement. Add this class right after the code for Measurment Class Scaled should meet these requirements:

There is an integer property named Side

There is a default constructor that initializes Side to the value 8

There is a constructor with two parameters that uses the first parameter to initialize Forward and uses the second parameter to initialize Side.

There is a method that overrides getAdvance which returns the product of Side and Forward

Code:

 static void Main(string[] args) { Test1(); Test2(); WriteLine("Done"); ReadKey(); } static void Test1() { WriteLine("test1"); Measurement m = new Measurement(); if (m.Forward != 7) { WriteLine("default Forward not correct"); } if (m.getAdvance() != 49) { WriteLine("getAdvance with default constructor incorrect"); } m = new Measurement(5); if (m.Forward != 5) { WriteLine("Forward not set correctly by constructor"); } if (m.getAdvance() != 25) { WriteLine("getAdvance with value set by constructor parameter incorrect"); } } static void Test2() { WriteLine("test2"); Scaled sc = new Scaled(); if(sc.Side != 8) { WriteLine("default Side not correct"); } if (sc.Forward != 7) { WriteLine("default Forward not correct"); } if (sc.getAdvance() != 56) { WriteLine("getAdvance with default constructor incorrect"); } sc = new Scaled(5, 11); if(sc.Side != 11) { WriteLine("Side not set properly by constructor"); } if (sc.Forward != 5) { WriteLine("Forward not set correctly by constructor"); } if (sc.getAdvance() != 55) { WriteLine("getAdvance with value set by constructor parameter incorrect"); } } } class Measurement { public int Forward { get; } public Measurement(int forward) { Forward = forward; } public Measurement() { Forward = 7; } public virtual int getAdvance() { return Forward * Forward; } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!