I need some help i need to do this in C#
Objectives:
• Create an application that uses a dictionary collection to store
information about an object.
• Understanding of abstract classes and how to use them
• Utilize override with an abstract class
• Understanding of Interfaces and how to use them
• Implement an Interface to create a “contract” between
classes.
• Compare and contrast inheritance and interfaces.
Instructions:
Interface:
Create an interface called ITrainable which contains the
following:
Dictionary Behaviors{ get; set; }
string Perform(String signal);
string Train(String signal, string behavior);
Here is an explanation of each of the signatures above; (Note: The
implementations are described below but should be in the class that
implements the interface, not the interface itself):
Dictionary Behaviors{ get; set; }
• A dictionary property named Behaviors to be implemented in
classes that implement ITrainable
o The key (a string) is the signal the trainer/user will use to ask
the animal to perform a behavior.
o The value (a string) is the behavior the animal will perform when
it sees the signal.
string Perform(String signal);
string Train(String signal, string behavior);
• A method named Perform to be implemented in classes that
implement ITrainable.
o Needs a string parameter
o Fetch the behavior from the Behaviors dictionary based on the
signal.
o Should return a string describing how the animal performed the
behavior
in response to the signal.
• A method named Train to be implemented in classes that implement
ITrainable.
o Needs a string parameter that holds the signal sent by the
user.
o Will add the behavior to the Behaviors dictionary using the
signal as the
key
o Should return a string describing how the animal has been trained
and
will respond to the specified signal.
Base Abstract Class:
Create a base abstract class named Animal which contains the
following properties and fields:
• A property named Species. This will hold the animal’s name (i.e.
dolphin)
• A field named _foodConsumed to keep track of how much food the
animal has
consumed.
• A field named _treat used to store the name of the food this
animal likes to eat
as a treat. (like fish for dolphins, rats for snakes). This will
need to be set to protected access since it will be used in
subclasses to set the value unique to each animal.
The following methods:
• An Eat method
o Tracks how much food has been consumed.
o If the animal eats over 4 times it should trigger the Poop()
method and
reset the _foodConsumed field.
o It should return a string describing how the animal ate the food
that looks
like this: "The dolphin ate a herring”
• A MakeNoise method
o This will be overridden later and should be virtual.
o This should return a string. This will be overriding later but
should return a
default string. (If your code is correctly created you should not
see the default in your working application.)
• A Poop method
o This should not return anything.
o This should write out to the console that the animal has pooped.
For ex:
"The dolphin pooped!”
Animal Classes:
You will need to implement at least 6 animal classes all should
inherit from the Animal base class.
• The constructors will need to initialize the Species and
Trainable properties as well as the _treat field.
• An overriding method named MakeNoise that returns a string that
describes the animal making noise. Ex: “A gargled roar comes from
the alligator.”
Some animals are trainable (dogs, dolphins, even cats) and some
aren’t (snakes, fish etc) and your application should reflect that.
At least half of the animals should implement the ITrainable
interface. This will mean they will be required to implement the
properties and methods as described above in the Interface
section.
• The Perform method should return a string similar to: "After you
signaled clapping hands the otter will now perform the 'jump
through the hoop' behavior."
• The Train method should collect the signal and behavior strings
and input them into the Behavior dictionary and return a string
such as: "The dolphin learned to slap it’s tail when you point to
the sky."
• Contain a Behaviors property that will hold the signals and
behaviors the given animal can perform based on what the user
enters.
Zookeeper Application:
Your main program application class should have the
following:
• A List object which will contain all the animals you
create.
• A method which welcomes the user and adds instances of each
animal into the
List object.
Your application should list the animals you’ve initialized,
specify which are trainable, and give the user the option of
selecting one.
Upon selecting an animal it will announce which animal was
selected and then provide a menu for activities the user can do
with the selected animal:
Training:
If the user selects Training, the program should ask the user what
behavior they would like to teach the animal and what signal they
will associate with the behavior. The program then stores this
information and reprints the menu:
Feeding the Animal:
For feeding an animal a treat (this is for all animals, not just
the trainable ones) it produces the following result, printing the
string produced by the Eat() method in the Animal base class:
Get the animal to perform a behavior:
When signaling the animal, if the animal is trainable, then the
program should ask the user for the relevant signal. If the animal
is not trainable a message should show to the user: “The animal you
selected is not a trainable animal. Please select a different
activity or exit to select a different animal.”
If the signal is in the dictionary it should respond. (If it is not
a message should be shown “The dolphin does not know this signal.
Train it to recognize this signal and associate it with a
behavior.” )
Make noise:
When this option is selected the animal should make a noise: Or the
user can select a different animal.
I need some help i need to do this in C# Objectives: • Create an application...
IN C# Objectives: Create an application that uses a dictionary collection to store information about an object. Understanding of abstract classes and how to use them Utilize override with an abstract class Understanding of Interfaces and how to use them Implement an Interface to create a “contract” between classes. Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the following: Dictionary<string, string> Behaviors{ get; set; } string Perform(String signal); string Train(String signal, string behavior);...
Assignment Requirements
I have also attached a Class Diagram that describes the
hierarchy of the inheritance and interface behaviors . The link to
the PDF of the diagram is below
MotorVehical.pdf
Minimize File Preview
User Define Object Assignment:
Create a Intellij Project. The
Intellij project will contain three user defined
classes. The project will test two of the User Define Classes by
using the invoking each of their methods and printing the
results.
You are required to create three UML...
C# Programming : Create a housing application for a property manager. Include a base class named Housing. Include data characteristics such as address and year built. Include a virtual method that returns the total projected rental amount. Define an interface named IUnits that has a method that returns the number of units. The MultiUnit class should implement this interface. Create subclasses for MultiUnit and SingleFamily. SingleFamily should include characteristics such as size in square feet and availability of garage. MultiUnit...
I tried to complete a Java application that must include at a minimum: Three classes minimum At least one class must use inheritance At least one class must be abstract JavaFX front end – as you will see, JavaFX will allow you to create a GUI user interface. The User Interface must respond to events. If your application requires a data backend, you can choose to use a database or to use text files. Error handling - The application should...
C# - Inheritance exercise
I could not firgure out why my code was not working. I was
hoping someone could do it so i can see where i went wrong.
STEP 1: Start a new C# Console Application project and rename its main class Program to ZooPark. Along with the ZooPark class, you need to create an Animal class. The ZooPark class is where you will create the animal objects and print out the details to the console. Add the...
You must write C# classes which are used to manage product review data for Books and Cars. You will write an abstract class called Review which abstracts common properties (review rating and comments). You will then create an Interface responsible for the functionality to display the Reviewcontent. Then, you will create 2 concrete classes which inherit from Review and implement the Interface. Finally, you will create console applicationwhich will create 2 CarReview instances and 2 BookReview instances and display them...
Write an interface and two classes which will implements the interface. 1. Interface - StringVerification - will have the abstract method defined - boolean verifyInput( String input ); 2. class EmailVerification implements StringVerification - implement the verifyInput() method in EmailVerification class. The method should validate a user input String, character by character and see the input string has a dot (.) and an at the rate (@) character in it. If any of the condition wrong the verifyInput method will...
Homework 3: Input Validation 1 Objectives control structures console-based user input using Scanner class writing complete programs using two classes: client and supplier 2 User Interface Specification This is a console-based I/O program. Display should go to System.out (print or println) and the program will get user input using the Scanner class. The flow of execution should be as follows: When the program starts, display a one-line introduction to the user Display a menu with 5 options 1. validate zip...
Create an Item class, which is the abstract super class of all Items. Item class includes an attribute, description of type String for every item. [for eg. Book] A constructor to initialize its data member of Item class. Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details. Declare a constant RATE with value 0.25 Declare a method called calculateExtraCharge(), which returns a double value. Create the...
Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...