Skip to content

Instantly share code, notes, and snippets.

@CasonBarnhill
Created October 27, 2015 14:07
Show Gist options
  • Save CasonBarnhill/5b9b694d91bdec9095d0 to your computer and use it in GitHub Desktop.
Save CasonBarnhill/5b9b694d91bdec9095d0 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Week_2_day_1
{
//1. build classes for Human, Robot, Panda-
//2. All should have a "DisplayName" and a "DisplayGreeting" method. The name should return the value held in an instance variable "Name"-
//3. Robots should have a "StartUp" and "ShutDown" method.They should output "Started..." and "Shutdown..." respectively-
//4. Pandas and Humans should have a "Eat" method with an argument "food" which describes what to eat.It should then return "Yum, I ate {food}"-
//5. A Robot should have a property called 'IsTerminator' which returns if that robot is a terminator(instance variable)-
//6. All should have a "IsASleep" property which returns true/false if a panda and human is asleep and if a robot has been shutdown.
//7. Pandas and Humans have a "GoToSleep" and "WakeUp" method.
//Demo the functions you've created by creating different instances of each type you've made and calling the functions on them.
public abstract class Things
{
public string Name { get; set; }
public string DisplayName()
{
return Name;
}
private bool _isAsleep;
public bool IsAsleep
{
get
{
return _isAsleep;
}
}
public string GoToSleep()
{
return "Go to sleep";
}
public string WakeUp()
{
return "Wake up";
}
}
public class Human : Things
{
public string Food { get; set; }
public string Eat(string food)
{
return "Yum I ate {food}";
}
}
public class Robot
{
public string DisplayName()
{
return "Name";
}
public string DisplayGreeting()
{
return "Hello";
}
public string StartUp()
{
return "Start Up...";
}
public string ShutDown()
{
return "Shut Down...";
}
private bool _isTerminator;
public bool IsTerminator
{
get
{
return _isTerminator;
}
}
}
public class Panda : Things
{
public string GoToSleep { get; set; }
public string WakeUp { get; set; }
public string Food { get; set; }
public string Eat()
{
return "Yum I ate {Food}";
}
class Program
{
static void Main(string[] args)
{
Human Cason = new Human();
Panda Ling = new Panda();
Things[] Animals = new Things[2];
Animals[0] = Cason;
Animals[1] = Ling;
Robot startMode = new Robot();
var begin = startMode.StartUp();
var shutdown = startMode.ShutDown();
Console.WriteLine($"{startMode.DisplayName()}The robot's name is {startMode.DisplayName()}. Start status: {begin}. Shut down status: {shutdown}.");
Console.ReadLine();
}
//call different classes (i.e. Human, Robot, Panda)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment