Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Classes and Subclasses and Interfaces First up, you are going to create an interface, call it LabInterface. Interfaces describe properties or methods an object implementing

Classes and Subclasses and Interfaces

First up, you are going to create an interface, call it LabInterface. Interfaces describe properties or methods an object implementing the inheritance must have, but you cannot ever create an object of type interface (yes, this naming confusion creates problems when talking about user interfaces).

Interface:

That Interface (LabInterface) should require:

a method public string Print(); and

a public int ID, with setters and getters

Classes:

You are going to make one super and two sub classes.

Class LabSuper

This should have:

a public string Name

To implement the interface it will need a method public string Print(), and an Int ID, plus the setters and getters. just {get; set;} is fine.

Subclasses

[Hint: you make subclasses by using a notation like Class Subclass : Superclass]

Class LabSubA :LabSuper

Which has all the properties and methods of LabSuper and has an int demo.

Make Print() return a string which is all of the properties of the object (ID, Name, demo)

Class LabSubB :LabSuper

Which has all the properties and methods of LabSuper and has a double demo.

Make Print() return a string which is all the properties of the object (ID, Name, demo)

You will need to test this in main and make some objects for example:

Make one object of each sub type and test the Print method is working for each

(e.g. the two objects above and then printed with:

Console.WriteLine(obj1.Print());

Console.WriteLine(obj2.Print());

)

One handy thing you can do. Place a breakpoint on the foreach loop and run the code to that point.

Screenshot your locals watch window where you can see the objects youve created

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

design a simple performance appraisal system

Answered: 1 week ago