Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer all of the questions ASAP (within 30 minutes). I will thumbs up/rate if it's correct. Please it's urgent. //This is the first part

Please answer all of the questions ASAP (within 30 minutes). I will thumbs up/rate if it's correct. Please it's urgent.

image text in transcribed

//This is the first part answer Please answer second and third part according to first part

package SpecialQuiz;

public interface Swimmer {

void howToSwim();

} //

public class Fish implements Swimmer { private boolean vertabrates; private String edible; public Fish(boolean vertabrates, String edible) { super(); this.vertabrates = vertabrates; this.edible = edible; } @Override public void howToSwim() { } @Override public boolean equals(Object obj) { if (obj instanceof Fish) { Fish fish = (Fish) obj; return vertabrates == fish.vertabrates && edible.equals(fish.edible); } return false; } }

Design an interface named Swimmer with a void method named howToSwim (). Every class of a swimmer object must implement the Swimmer interface. Design a class named Fish. Write an equals method for the Fish class; have it override the Object equals method. Two Fish are equal if they have the same values of the instance variables vertabrates (a Boolean) and edible (a String). Design a class named Goldfish that extends Fish and implements Swimmer. Implement howToSwim to display the message It is swimming. Then design a class named BubbleEye that extends Fish and implements Swimmer. Implement howToSwim to display the message "It is swimming". Draw a UML diagram that involves Swimmer, Goldfish, BubbleEye and Fish. Write a test program that creates an array of five Fish objects. For each object in the array, display the result of equals method with another object of the same array and invoke its howToSwim method if it is swimmer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions