Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 5

using System;

namespace Assignment2
{
class animals
{
static void Main(string[] args)
{
// string aname;

Cat cat = new Cat();


Mouse mouse = new Mouse();

Console.WriteLine("------------------Pet Simulator---------------");
Console.WriteLine("----------------------------------------------");
Console.WriteLine();
Console.WriteLine("What is your name? ");
string aname = Console.ReadLine();
Console.WriteLine("||||||||||||||||||||||||||||||||||||||||||||||");
Console.WriteLine("\t\tWELCOME {0}", aname);
Console.WriteLine("||||||||||||||||||||||||||||||||||||||||||||||");
Console.WriteLine("||||||||||||||||||||||||||||||||||||||||||||||");
Console.WriteLine("Please Choose Between [(A)CAT__(B)MOUSE]");
string chonum = Convert.ToString(Console.ReadLine());
if(chonum == "a" || chonum == "A")
{

Console.WriteLine("----------------------------------------------");
Console.WriteLine("What is the name of the cat?");

Console.WriteLine("----------------------------------------------");
cat.Name = Console.ReadLine();
Boolean catback = false;
while( catback == false )
{
Console.WriteLine("What would you like to do with the cat?");
Console.WriteLine("(1)DRINK (2)EAT (3)PLAY");

Console.WriteLine("----------------------------------------------");
int num = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
if(num == 1)
{
Console.WriteLine("Youre giving water!!!");
cat.drink();
}
else if(num == 2)
{
Console.WriteLine("Youre giving food!!!");
cat.eat();
}
else if( num == 3)
{
cat.run();
Console.WriteLine("After some time");
cat.back();
cat.getvelocity();
}
Console.WriteLine("Do you want to choose again?(Y/N)");
string yn = Convert.ToString(Console.ReadLine());
if(yn == "y" || yn == "Y")
{

}
else
{
catback = true;
Console.WriteLine("Thank you for playing");
}
}
}
else if (chonum == "b" || chonum == "B")
{
Boolean moback = false;
while(moback == false)
{
Console.WriteLine("What would you like to do with the Mouse?");
Console.WriteLine("(1)DRINK (2)EAT (3)PLAY");
int num2 = Convert.ToInt32(Console.ReadLine());
if (num2 == 1)
{
Console.WriteLine("Youre giving water!!!");
mouse.drink();
}
else if (num2 == 2)
{
Console.WriteLine("Youre giving food!!!");
mouse.eat();
}
else if (num2 == 3)
{
mouse.run();

Console.WriteLine("----------------------------------------------");
Console.WriteLine("After some time");
mouse.back();
mouse.getvelocity();
}
Console.WriteLine("Do you want to choose again?(Y/N)");
string ynask = Convert.ToString(Console.ReadLine());
if (ynask == "y" || ynask == "Y")
{

}
else
{
moback = true;
Console.WriteLine("Thank you for playing");
}

}
}
}
}

interface Icanmove
{
void run();
void back();
void getvelocity();
}
interface Icaneat
{
void eat();

}
interface Icandrink
{
void drink();

public abstract class Animal : Icanmove


{
public void run()
{
Console.WriteLine("\nThe animal starts to run!!!");
}
public abstract void back();
public abstract void getvelocity();

class Cat : Animal, Icaneat, Icandrink


{
private string name;

public string Name


{
get { return name; }
set { name = value; }
}
public Cat()
{

}
public Cat(string name)
{
Name = name;
}
// public void Ask()
// {
// Console.WriteLine("What is the name of the cat? {0}", Name);
// Console.WriteLine("=================================");
// Console.WriteLine("The name of the cat is {0} ",Name);
// }

public void eat()


{
Console.WriteLine("----------------------------------------------");
Console.WriteLine($"\t{Name} the cat starts eating!!!");
Console.WriteLine("----------------------------------------------");
}
public void drink()
{
Console.WriteLine("----------------------------------------------");
Console.WriteLine($"\t{Name} the cat starts drinking!!!");
Console.WriteLine("----------------------------------------------");
}
public override void back()
{
Console.WriteLine("----------------------------------------------");
Console.WriteLine($"\t{Name} the cat is running back");
Console.WriteLine("----------------------------------------------");
}
public override void getvelocity()
{
Random rnd2 = new Random();
for (int j = 0; j < 1; j++)
{

Console.WriteLine("----------------------------------------------");
Console.WriteLine("\tWith a speed of {0} m/s", rnd2.Next(10));

Console.WriteLine("----------------------------------------------");
}
}

class Mouse : Animal, Icaneat, Icandrink


{
public void eat()
{
Console.WriteLine("----------------------------------------------");
Console.WriteLine("\tJerry the mouse starts eating!!!");
Console.WriteLine("----------------------------------------------");
}
public void drink()
{
Console.WriteLine("----------------------------------------------");
Console.WriteLine("\tJerry the mouse starts drinking!!");
Console.WriteLine("----------------------------------------------");
}
public override void back()
{
Console.WriteLine("----------------------------------------------");
Console.WriteLine("\tJerry the mouse is running back ");
Console.WriteLine("----------------------------------------------");
}
public override void getvelocity()
{
Random rnd2 = new Random();
for (int j = 0; j < 1; j++)
{

Console.WriteLine("----------------------------------------------");
Console.WriteLine("\tWith a speed of {0} m/s", rnd2.Next(10));

Console.WriteLine("----------------------------------------------");
}
}

}
}

You might also like