Create an interface named IRecoverable. It contains a single method named Recover(). Create classes named Patient, Furniture, and Football; each of these classes implements IRecoverable. Create each class’s Recover() method to display an appropriate message. For example, the Patient’s Recover() method might display “I am getting better.” Write a program that declares an object of each of the
three types and uses its Recover() method.
I am new to this language, it looks like they are similar to c++. so I'm trying to do c# problems like this can someone help with this? im referring to J.Farrell's book introduction to c#.
Loading
VulpesPosted Feb 19, 2015, 7:25 AM
using System;
interface IRecoverable
{
void Recover();
}
class Patient : IRecoverable
{
public void Recover()
{
Console.WriteLine("I am getting better.");
}
}
class Furniture : IRecoverable
{
public void Recover()
{
Console.WriteLine("I have recovered my furniture.");
}
}
class Football : IRecoverable
{
public void Recover()
{
Console.WriteLine("I have recovered my football.");
}
}
class Program
{
static void Main()
{
Patient p = new Patient();
p.Recover();
Furniture f = new Furniture();
f.Recover();
Football fb = new Football();
fb.Recover();
Console.ReadKey();
}
}
The output should be:
I am getting better.
I have recovered my furniture.
I have recovered my football.
Andariel SharpPosted Mar 10, 2015, 3:43 AM