Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem # 3: Create a drawing JFrame application that draws repetitive triangles, rectangles, and ovals. For this purpose, create a set of JPanels shape classes

image text in transcribed

Problem # 3: Create a drawing JFrame application that draws repetitive triangles, rectangles, and ovals. For this purpose, create a set of JPanels shape classes My Triangles. MyRects, and MyOvals. The data for class MyTriangles should include side length and number of triangles to be drawn and the number to be dra each line. The data of classes MyRects and MyOvals should include a width (non-negative) and a height (non-negative) and number of shaped to be drawn and the number to be drawn on each line. All data in each class must be private In addition to the data, each class should define at least the following methods: a A constructor with no arguments that sets the attribute to 0. b) A constructor with arguments that sets the attributes to the supplied values. c) Set methods for each individual piece of data that allows the programmer to modify any piece of data in a shape (i e. if you h you should have a method setSideLength) Get methods for each individual piece of data that allows the programmer rcad any piece of data in a shape (i.e. if you have a variable sideLength then you should have a method getSideLength) A draw method with the first linc a variable sideLength then d) c) public void paintComponent (Graphics g that is responsible of drawing its corresponding figure, and it would be called by JPanel draw a shape on the screen. In your JFrame application, you should ask the user for a shape to draw (ovals, triangles, or rectangles). The application dimensions randomly (from 50 to 100) and the number of shapes randomly frm (1 to 10) and the number of shapes on each line randomly between (1 to the number of shapes generated randomly at previous step) Sample Run: Included in the next question Problem #4: You need to implement a program that draws figures based on user choice. You need to use the classes for drawing should be read from the user via java GUIs. The user choice should also be taken via java GUIs and should be read as string until a user eaters "Stop". For string comparison you can use the following functions of the scanner class: d in the previous question to draw your shapes. Any data needed drawy 5tring input - ; input equale("Stop" The function equals compares the string given as parameter and the string stored in the String input if they are equal it returns true and if not false. The function returns true if the two strings are equal and false if the strings are not equal Note: Attached are sample output Not all required inputs are collected in this sample), the sample is for triangles of side length 75 and the number of shapes is 10, the number of shapes on each line is 3 Input Enter the shape you want (Triangles,Rectangles, Ovalsp: OK Cancel

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students also viewed these Databases questions

Question

What is meant by functional currency and how it is determined?

Answered: 1 week ago

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago

Question

soyuznye (all-Union, controlling enterprises directly from Moscow);

Answered: 1 week ago