Part 1: Overriding Methods

Note:  Please keep the programs that you create today, in case you have a question about your grades for the ICEs at the end of the quarter. When you're working with a partner, each person should save his-or-her own copy.

## ICE 13.1: Overriding Inheritance

Afterward study the code in order to determine how/when the inheritance overriding occurred.

NOTE: This program utilizes a super class and sub class.

## ICE 13.2: Overriding: A Bit More Complicated Inheritance

Afterward study the code in order to determine how/when the inheritance overriding occurred.

NOTE: This program utilizes a super class, a sub class, and a sub-sub class.

When you get done with this exercise, show your Instructor, then go on to the next section.

## ICE 13.3: Overriding: Build a SafeRobot

The basic Robot class that we've been using is very useful. It's a Robot, and can do things like move, turn left, and pick things up. This is all great, but one of the problems with this is that if you make a mistake, the you'll probably end up breaking the robot.

• If your Robot moves into a Wall, the Robot will break (splat!)
• If your Robot tries to pick up a Thing in an empty intersection, the Robot will break (splat!)
• If your Robot tries to put a Thing down when it's got an empty backpack, the Robot will break (splat!)

Your job in this ICE is to create a new type of Robot named SafeRobot.

You should override the move(), pickThing(), and putThing() methods, so that the robot will not break.

Even if the Robot is standing in front of, and facing a wall, your SafeRobot's move() method should be smart enough to determined "Is the path in front clear?" Only if the answer is yes should the robot move forward.

Start with any file that you'd like (even one you were recently working on).

Make sure you test out your methods (i.e., put a Wall in front of the robot and try walking the robot into the Wall in order to check that move() is safe; try picking up a Thing that isn't there; try putting down a Thing when the backpack is empty, etc)

When you get done with this exercise, show your Instructor.