Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA CODE: A toolbox contains various named tools that can be used in a way that depends on the specific tool The tool interface is

JAVA CODE:

image text in transcribed

A toolbox contains various named tools that can be used in a way that depends on the specific tool The tool interface is interface Tool extends Cloneable String getName (); void use(); Object clone(); There are several classes of tools for our problem domain: Eraser, Pencil, Protractor, Ruler, Paper A toolbox can return (get()) to the client a copy of a stored tool object based on its name, or throw NoSuchElementException if no tool exists in the toolbox with the given name. The toolbox can be populated with new tools (the add() method) The toolbox interface is: interface Toolbox { void add (Tool tool); Tool get (String toolName); a. Use the Prototype pattern to design the toolbox and tools. Write the UML class diagram. b. Implement the design in Java. Write contracts for all methods To keep things simple, the Tool.use() method should just println("Using " this.getName)) c. Write a ToolTest class with a main() method that exemplifies how the toolbox is used: - create the toolbox populate it with one tool of each kind - call get for several named tools and 'use' them

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 Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

=+ 9. Why cant the Fed control the money supply perfectly?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago