Yorkville High School Computer Science Department
Yorkville High School Computer Science Department on Facebook  Yorkville High School Computer Science Department Twitter Feed  Yorkville High School Computer Science Department on Instagram

Yorkville High School Computer Science

ASSIGNMENTS: No Current Assignments

AP Computer Science :: Projects :: Old MacDonald's Farm

Rubric
Lesson
Due: Database Error

Problem

In this project, you will be creating Old MacDonald's Farm using inheritance. Every animal on the farm has a type (such as cow or pig) and makes a sound (such as moo or oink). This project was adapted from a project originally conceived by Roger Frank of Ponderosa High School in Parker Colorado. You can watch the video below if you've never heard the song "Old MacDonald" before:

Old MacDonald's Farm contains the following interface:

public interface Animal {
    public String getSound();
    public String getType();
}

Instructions

Using the interface detailed above, create Old MacDonald's Farm with the following properties:

  1. Create classes for Cow, Chick, and Pig, as well as another animal of your choice that implement the interface.
  2. Create a Farm class that creates animal of all four types and outputs their sound in the form "The TYPE goes SOUND."
  3. Modify the Chick class so it can say two sounds. Each sound should have an equal probability of being made.
  4. Create a new class called NamedCow that works exactly like a cow, but also has a name that is set at the beginning and can be found using a getName() accessor.
Yorkville High School Computer Science Department on Facebook Yorkville High School Computer Science Department Twitter Feed Yorkville High School Computer Science Department on Instagram