Use the following class description to create an inheritance hierarchie. The cod
ID: 3736589 • Letter: U
Question
Use the following class description to create an inheritance hierarchie. The code has to be written in C#.
Class name: Human: Able to use technology, build houses and landscapes, cook food, do math, and other various complicated tasks. Can travel on foot, on bicycle, on car, etc. Humans are omnivores, meaning they can eat both plants and meat.
Class name: Monkey: Cannot use technology or complete most complicated tasks. Can travel on foot, swinging on trees (depending on the monkey and their location), running across tree branches (depending on location), etc. Monkeys are also omnivores, allowing them to eat both plants and meat.
Explanation / Answer
---------Inheritance Hierarchie ---------
Code: -
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace Rextester
{
class Mammal{
bool canTravelOnFoot, omnivores;
}
class Human : Mammal{
bool canUseTechnology, buildHousesAndLandscapes, cookFood, doMath, complicatedTasks,canTravelOnBicycle, canTravelOnCar;
public Human(){
}
}
class Monkey : Mammal{
bool canSwingOnTrees, canRunAcrossTreeBranches;
public Monkey(){
}
}
public class Program{
public static void Main(string[] args){
Monkey m = new Monkey();
Human h = new Human();
Console.WriteLine("You are here");
}
}
}
Description: -
Here above i have created three classes in which one is parent class & othere two are child clasess.
Parent Class- Mammel
Child Class - Human, Monkey
Common Properties - canTravelOnFoot, omnivores
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.