iOS Development

Course No. 10-152-139

Assignment 23-1

The Kennel

  • Create a new Xcode command-line project. Name the project Assignment-23-1.
  • Make sure that you write this project to prevent memory leaks and retain cycles.

The Kennel Class

  • Create an Objective-C class named Kennel. The Kennel class will have the follow features.
    1. A string for the name of the kennel.
    2. An NSMutableArray to hold pets that are staying at the kennel.
    3. A method to add a new pet to the kennel. This will add the pet to the array of pets and add the kennel to the pet’s kennel property.
    4. A method to calculate how much food the kennel will need for the week.
    5. Override the description method to create a weekly report for the kennel. The report should contain a list all the pets and how much of what food they need. After the list of pets, append the total amount of food needed for the week. Create the full report as a string and return it.

The Pet Class

  • Create an Objective-C class named Pet that will be the base class for all pets. This class will have these features.
    1. A string property for the name of the pet.
    2. A float property for the weight of the pet.
    3. A float property for the amount of food the pet needs for a week.
    4. A string property for the type of food the pet needs.
    5. A Kennel property that will hold a pointer to the kennel where the pet is staying.

The Dog Class

  • Create a subclass of the Pet class named Dog. The class will add these features to the base class.
    1. A string property for the breed of the dog.
    2. A description method override that returns a string for the dog like this:

The SmallDog Class

  • Create a subclass of the Dog class named SmallDog. This class will add these features to its base classes.
    1. A description method override that returns a string like this. You must get the string from the superclass description method and just add the text, "Small " at the beginning.

The Cat Class

  • Create a subclass of the Pet class named Cat. The class will add these features to the base class.
    1. A string property for the length of the cat’s fur. It will hold information like, “Long Haired”, or “Short Haired”.
    2. A description method override that returns a string like this:

In the main function.

  • Perform all the following tasks in the main function.
    1. Import all the classes you have created.
    2. Create an instance of the Kennel class.
    3. Create several instances each of the Dog, SmallDog, and Cat classes.
    4. Assign appropriate values to the properties of the instances.
    5. Add the pet instances to the kennel using the method in the Kennel class.
    6. Output the Kennel report with just the following line of code.