Question
C# - Console Applications (**READ INSTRUCTIONS VERY CAREFULLY**) This homework will be based on Polymorphism . For this assignment there will be 1 main program
C# - Console Applications (**READ INSTRUCTIONS VERY CAREFULLY**)
This homework will be based on Polymorphism.
For this assignment there will be 1 main program file, 1 Car class, 1 Animal class, 1 Human class, 1 Dog class and 1 Cat class.
The Animal class is the base class. To make things easy, it will only have one private variable "int Age" and one called "string Name". It has a basic constructor and an overloaded constructor, one accessor for each of the private variables and finally a "display" function which will display the Name and age (**If the Animal has not been initialized, meaning the basic constructor was used and it set up the name to be "none" and age to be 0, then it will simply display "EMPTY"**)
The Human class is derived from the Animal class. This class has one private variable called "bool license". This is to check if the person has a license or not, so its either true or false. There is a basic constructor and an overloaded constructor (**Remember to initialize the base class as well!!**). One accessor for the private variable and finally a "display" function which will display Name, Age, and License (**it displays either "has license" if it is true or "no license" if false**).
The Dog class is derived from the Animal class. This class has one private variable called "bool loud". This is to see how loud the dog is and it is either true or false. There is a basic constructor and an overloaded constructor (**Remember to initialize the base class as well!**). One accessor for the private variable and finally a "display" function which will display Name, Age, Loud (**it will display either "bark" if not loud or "barkbarkbark" if loud**).
The Cat class is derived from the Animal class. This class has one private variable called "bool needy". This is to see if the cat needs someone to play with. There is a basic constructor and an overloaded constructor (**Remember to initialize the base class as well!**). one accessor for the private variable and finally a "display" function which will display Name, Age, Needy (**it will display either "purr" if it is needy or "meow" if it is not needy**).
The car class is not derived from anything. This class has a private array of 5 Animals called "Animal [] seat;" This means that the car has seats, but each seat holds an animal. There is a basic constructor and an overloaded constructor (**Remember to initialize the seats array to be of size 5 for both. The basic constructor only needs to initialize the 5 default constructor Animals *EMPTY*, while the overloaded needs to receive an array of 5 animals from the main to initialize the seats with those animals**). one accessor for the private variable, a display which shows the contents of the car, so it will display the animals in all 5 seats... it will display "EMPTY" if the seat is empty because an empty seat has the Animal default constructor used which based on the display function for Animal, it displays empty in that case. Display it nicely, such as "Seat 1 has Tim Johnson which is 23 and has license" etc.
In the main, you will read from all the files first. The following are the files and their contents. You are responsible for creating them and coming up with the data in the files (I will use my own files when grading).
(**Please send files as well, DO NOT use this code "Encoding.UTF8" in the project!!**)
"humans.txt" - Has the Name, Age, and License of 10 people (License means it will have "true" or "false").
"dogs.txt" - has the Name, Age, and Loudness of 10 dogs (Loudness is "true" or "false").
"cats.txt" - has the Name, Age, and Needy of 10 cats (Needy is "true" or "false").
Place each one of these humans, dogs, cats into 3 different arrays of size 10. These three arrays are simply to hold all the options for the user in the next section of code.
Create a default car (meaning all 5 seats are "EMPTY" because we have 5 default animals in the 5 seats and a default animal is "EMPTY" because of what is stated above for the Animal class).
Display to the user the contents of the car (should show all seats empty) *array of 0 is the driver*
Create an array of size 5 of Animals
Give the user Options. 1. to add Human, 2 to add Dog, 3 to add Cat, 4 to remove, 5 to check. *There is a loop so the person can do this as many times until the user enters 5 to check AND it is a valid configuration. Make it look nice with clearing the screen and re-displaying the contents of the car each time a change is made so there is no clutter on the screen.*
Selecting 1-4 will lead to the question "Which seat would you like to perform this action on". Change the contents of that seat with the choice the user picked in the Options.
Selecting 5 will lead to the program checking if the current configuration is valid, it will display "Congrats, you are on your way on the road happily" and the program will end. If the configuration is not valid, it will display "Sorry this setup is not good because of the following reasons *lists reasons*, please try again"
Reasons for it to be invalid are 1. driver does not have a license. 2. you have two or more loud dogs. 3. You have a cat which is needy.. but there is no one for it to play with (**driver not included and a needy cat does not like a loud dog so having a driver, a needy cat and a loud dog would not make the cat happy, so this setup is invalid**).
**AGAIN THIS IS A C# PROGRAM. NO JAVA! I WOULD LIKE TO POST THIS QUESTION JUST ONCE. DO NOT USE "Encoding.UTF8" AND MUST BE DONE ON CONSOLE APPLICATIONS! READ INSTRUCTIONS CAREFULLY!!**
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started