Question: Use loops and conditions in Java to produce shapes out of Unicode characters. The program's user menu affects a switch-statement, which in turn affects the

Use loops and conditions in Java to produce shapes out of Unicode characters. The program's user menu affects a switch-statement, which in turn affects the program's action. A menu is displayed which asks a user to select a shape:

1 square

2 circle

3 diamond

The program then asks the user to enter any character with which to fill the shape, such as *, or enter nothing for the program's default character set. This default entails filling the shape with the characters of the alphabet according to their sequential Unicode decimal value (see http://unicodelookup.com ). Therefore, the number of characters in each shape should at least accommodate the entire alphabet. For example, a square might look like: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j Program must draw these shapes iteratively with loops such as: for, while, do while (do not use GUI methods).

A user menu entails cases that call separate shape generating methods. The methods must be members of separate classes Square, Circle, Diamond that descend from the abstract class Shape

Create an interface DisplayCharacters and another class Characters. Characters contains a method useChar() either the default alphabet or the user's selected character to comprise a shape. Keeping with object oriented principles, the Characters class is distinct from the Shape class, so Shape makes use of Characters' useChar method via composition.

Program generates output files of either square.txt, circle.txt or diamond.txt. then reads into an array the characters comprising the shape file in #4. The program then correctly displays (prints) that shape on the screen.

Revise program to use generics for the classes, interface and methods created. Call this version GenericCharShapes.java. Demonstrate restrictions of generics with respect to Shape class hierarchies, such as versus , or .For generic methods, for example, a method average(T num) can compute the average value of ints, doubles or chars, or countChars(Shape s) can count the the number of characters in a circle, square or diamond

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!