Question: Please use java language and comment as much as you can. I am learning. Create an interface called Speakable that contains a void speak() method.
Please use java language and comment as much as you can. I am learning.
Create an interface called Speakable that contains a void speak() method. Define 2 classes, Man and Woman, which are subclasses of the Human class, and implement the interface Speakable. The speak() method should be abstract at the superclass level, and defined at the subclass levels.
Define only 1 attribute at the Human class level: name. At the Woman subclass, add the attribute favoriteStore, and at the Man subclass, add the attribute favoriteSport. In the speak() method of the Woman subclass, print out Hi, my name is and the name attribute, and say my favorite store is and the name of the store. In the speak() method of the Man subclass, print out Hello, my name is and the name attribute, and say my favorite sport is and the name of the sport.
Dont forget to define a constructor at the superclass level and at the subclass levels. Also, dont forget the toString() method at the superclass and at each subclass.
In the driver class called Conversations, create an ArrayList called people, of type Speakable. In a method called createPeople(), which is called from main, add 3 Woman and 3 Man objects to the people arrayList. Ask the user to enter all the attributes of each object before creating each Woman or Man object. Place each object in the people arrayList.
In another method called processConversations(), also called from main, use a for-loop to iterate over Speakable objects, and invoke the speak( ) method.
Hint: To create an arrayList of Speakable objects, code the following:
ArrayList
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
