Exercise: Cloud Resource Management

Implement a comprehensive DevOps resource manager using an interface inheritance chain.

Problem statement

A cloud platform categorizes its infrastructure using hierarchical contracts. A scalable virtual machine must satisfy the requirements of a basic resource, a computable resource, and a scalable resource. Implement this interface hierarchy and satisfy the entire chain within a single concrete class.

Task requirements

  • Define a three-level interface inheritance chain: IResource, IComputableResource, and IScalableResource.

  • Create a VirtualMachine class that implements the most derived interface in the chain.

  • Provide concrete behaviors for all capabilities inherited throughout the contract chain.

  • Ensure your implementation works with the provided Program.cs logic.

Constraints

  • IComputableResource must inherit from IResource, and IScalableResource must inherit from IComputableResource.

  • VirtualMachine must explicitly declare implementation of only the IScalableResource interface.

  • The implementations for Start, AssignTask, and ScaleUp must output exactly "Virtual machine booting up...", "Task assigned to virtual machine.", and "Allocating additional CPU and RAM...", respectively.

  • You must place all types in the CloudPlatform file-scoped namespace.

Good luck trying the exercise! If you’re unsure how to proceed, check the “Solution” tab above.

Get hints

  • Use the colon : syntax on an interface definition to inherit from another interface.

  • When a class implements a derived interface, it is required to implement all methods from the parent interfaces as well.

  • You do not need to explicitly list the parent interfaces on the class declaration, because listing the most derived interface (IScalableResource) is sufficient.

Exercise: Cloud Resource Management

Implement a comprehensive DevOps resource manager using an interface inheritance chain.

Problem statement

A cloud platform categorizes its infrastructure using hierarchical contracts. A scalable virtual machine must satisfy the requirements of a basic resource, a computable resource, and a scalable resource. Implement this interface hierarchy and satisfy the entire chain within a single concrete class.

Task requirements

  • Define a three-level interface inheritance chain: IResource, IComputableResource, and IScalableResource.

  • Create a VirtualMachine class that implements the most derived interface in the chain.

  • Provide concrete behaviors for all capabilities inherited throughout the contract chain.

  • Ensure your implementation works with the provided Program.cs logic.

Constraints

  • IComputableResource must inherit from IResource, and IScalableResource must inherit from IComputableResource.

  • VirtualMachine must explicitly declare implementation of only the IScalableResource interface.

  • The implementations for Start, AssignTask, and ScaleUp must output exactly "Virtual machine booting up...", "Task assigned to virtual machine.", and "Allocating additional CPU and RAM...", respectively.

  • You must place all types in the CloudPlatform file-scoped namespace.

Good luck trying the exercise! If you’re unsure how to proceed, check the “Solution” tab above.

Get hints

  • Use the colon : syntax on an interface definition to inherit from another interface.

  • When a class implements a derived interface, it is required to implement all methods from the parent interfaces as well.

  • You do not need to explicitly list the parent interfaces on the class declaration, because listing the most derived interface (IScalableResource) is sufficient.

C# 14.0
namespace CloudPlatform;
// TODO: Define IResource
// TODO: Define IComputableResource inheriting from IResource
// TODO: Define IScalableResource inheriting from IComputableResource
// TODO: Define VirtualMachine implementing IScalableResource