42.9k views
1 vote
Using C#, implement the following class hierarchy: A Vendor class represents an entity that sells goods to you. A Customer class represents objects that buy goods from you. A Shop class represents objects that buy goods from you and sell goods to you.

1 Answer

4 votes

Final answer:

In C#, you can implement the class hierarchy with Vendor as the base class and Customer and Shop inheriting from Vendor. Here is an example.

Step-by-step explanation:

Class Hierarchy:

In C#, you can implement the class hierarchy as follows:

public class Vendor
{
// Vendor class code
}

public class Customer : Vendor
{
// Customer class code
}

public class Shop : Vendor
{
// Shop class code
}

The Vendor class is the base class, and both the Customer and Shop classes inherit from it.

Example:

Vendor vendor = new Vendor();
Customer customer = new Customer();
Shop shop = new Shop();

In this example, we create objects of each class.

User Frank De Jonge
by
8.5k points