Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I am having trouble with my Java project. Please try and keep to the assignment. I saw a similar question and the person answering

Hi I am having trouble with my Java project. Please try and keep to the assignment. I saw a similar question and the person answering kinda threw away some of the instructions.I have most of it down but don't understand how to use the lamdba expressions. Thanks a ton!

Create an application that collects and displays various animals.

Console

Welcome to the Animal List Type of animal: 1 - Dog 2 - Cat 3 - Turtle Choose type: 2 Enter animal's name: Percy Continue? (y/n): y Type of animal: 1 - Dog 2 - Cat 3 - Turtle Choose type: 3 Enter animal's name: Yertle Continue? (y/n): n And now let's hear the animals speak ------------------------------------ Percy the Cat says 'Meow' Yertle waves! (turtles don't have vocal cords) 

Create an abstract class named Animal. This class should have a private name variable of type String, and contain these constructors and methods:

public Animal(String name) public String getName() public void setName(String name) public String getNameAndType() public abstract void speak() protected void speak(Consumer consumer)

The getNameAndType() method should return the animal's name concatenated with 'the' and the type of the class (example: 'Percy the Cat').

Create subclasses named Dog, Cat, and Turtle that extend the Animal class. These classes should have constructors that call the constructor of the parent class.

When the subclasses override the abstract speak() method, they should call the protected speak() method of the parent class and pass it a function. This function contains the functionality for the speak() method for that subclass.

You should be able to easily modify this class so an animal 'speaks' by printing data to the console or by displaying a GUI dialog box.

After the user has entered all the animals they want, each animal that they've entered should 'speak'.

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

Progress Monitoring Data Tracking Organizer

Authors: Teacher'S Aid Publications

1st Edition

B0B7QCNRJ1

Students also viewed these Databases questions

Question

what are the provisions in the absence of Partnership Deed?

Answered: 1 week ago

Question

1. What is called precipitation?

Answered: 1 week ago

Question

1.what is dew ?

Answered: 1 week ago