This assignment addresses the following primary course learning objectives: · Te
ID: 3589663 • Letter: T
Question
This assignment addresses the following primary course learning objectives:
· Techniques for extending behavior of classes including inheritance and polymorphism
· Solve problems that require design and implementation of multiple classes including class hierarchies
· Package/library design and implementation
· The importance of using abstract classes to support encapsulation principles
This assignment also provides you an opportunity to engage with the following objectives:
· Document object-oriented designs using diagramming techniques and notations (e.g., UML)
· Utilize graphical IDEs
· Importance and limitations of testing during and after development
· Write and review test cases and unit tests based on documented pre and post conditions
Program Background
Building upon the concepts from the previous assignment, there are other advantages to building class hierarchies, including the utilization of polymorphism. Polymorphism allows the programmer to access an object's more specific behaviors through a reference of a super type. This has a number of applications, including being able to collect multiple related objects in a single collection, such as an array, allowing the objects to be treated "generally" according to their shared type. However, the behavior of the objects will be according to their specific type.
Program Description
For this assignment you will complete two hierarchies, each with abstract base classes. Some of the classes have been provided in order to demonstrate some of the required techniques that will be necessary in completing the others. These classes will used in creating a small simulation game that will require you to create and maintain a collection of related classes utilizing polymorphism. The task of the game centers around resource management and triage, which are useful skills in many disciplines. Games are often created in order to train such skills. In this game, the player will have the role of a Zoo Keeper with limited resources with the task of keeping a number of animals happy and healthy.
The following classes are required in your solution. Each class name below is shown in fully-qualified form to illustrated the required package structure for your solution. Class name links provide Javadoc descriptions for the required data members (ie, fields in javadoc) and methods. Note that you are allowed, and some cases may need to, add additional helper methods and data members. When doing so, consider the level of access that these additional members require at a minimum. You may also browse the entire project specification
Provided classes:
· zoo.foods.Food
· zoo.animals.Penguin
· zoo.animals.Tiger
· zoo.animals.FoodMappings
· zoo.ZooKeeper
· zoo.ZooPantry
ZooDriver
· ZooTester
Classes you must write:
· zoo.foods.Fish
· zoo.foods.Frui
· zoo.foods.Grass
· zoo.foods.Meat
· zoo.foods.Seeds
· zoo.animals.Animal
· zoo.animals.Dolphin
· zoo.animals.Elephant
· zoo.Zoo
http://www.filedropper.com/hw2zookeepergame-starter1
Documentation of classes to create: http://www.filedropper.com/documentation_4
Explanation / Answer
import random def main(): word = input("Please enter a word: ") print(scramble(word)) def scramble(word): char1 = random.randint(1, len(word)-2) char2 = random.randint(1, len(word)-2) while char1 == char2: char2 = random.randint(1, len(word)-2) newWord = "" for i in range(len(word)): if i == char1: newWord = newWord + word[char2] elif i == char2: newWord = newWord + word[char1] else: newWord = newWord + word[i] return newWord main()