solution

This Program should consist of 4 classes (Airplane, Bird, Flight, and ThingsThatFly).

Write a program to process different objects that can fly in a systematic mantter through the same interface they implement.

  • Interface Flight: Contain only one void method fly() (no parameters).

  • Two non-abstract classes Airplane and Bird that implement the Flight interface.

    • Airplane class:

      • Three attributes: model and year built

    • Bird class:

      • One attribute: type

Besides the contructors and getters/setters, both the Airplane and Birdclasses should implment the fly method. The Airplane’s fly method should print “I’m an airplane that relies on an engine to fly.” The Bird’s fly method shoud print “I’m a bird who flaps wings to fly.” Each should also include a toString() method.

Hint: For the toString method, use the output of the program (see below) to determine the format of the string to return.

  • Appication program ThingsThatFly

    • Create one Airplane object and two Bird objects. The program must store these objects in one array or array list.

    • The program must use a loop to print the objects and how they fly. Your program should have the following output:

Airplane [model=Boeing 747, year=2016]: I'm an airplane that relies on an engine to fly.
Bird [type=Eagle]: I'm a bird who flaps my wings to fly.
Bird [type=Hummingbird]: I'm a bird who flaps my wings to fly.

1b.

This program extends the previous program and consist of 5 classes (Airplane, Bird, Flight, Movement, and ThingsThatMove).

This exercise extends Exercise 2. Define another interface Movement that extends the interface Flight from Exercise 2. It contains two new abstract methods walk() and jump(). Both have no parameters and no return values. Now make the Airplane and Bird classes implement the Movement interface. The program that contains the main method should be called ThingsThatMove. It should create the same objects as in Exercise 2 and store them in an array.

Your program should have the following output:

Airplane [model=Boeing 747, year=2016]:
I rely on my engine to fly.
I tax on my wheels.
I cannot jump.
Bird [type=Eagle]:
I flap my wings to fly.
I walk on my feet.
I jump by leaping from my feet.
Bird [type=Hummingbird]:
I flap my wings to fly.
I walk on my feet.
I jump by leaping from my feet

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!