Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java Please place SCREENSHOTS of output, a brief summary, and descriptions. ASSESSMENT You will be assessed for your competence in programming and writing effective

In Java

Please place SCREENSHOTS of output, a brief summary, and descriptions.image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

ASSESSMENT You will be assessed for your competence in programming and writing effective code. The purpose of all coding exercises in this course is the make your code more: modular programming design: you should at all times seek to achieve a modular programming design when submitting your work for grading (severe deductions apply otherwise). readable : your code should read like a story to a programmer. If I can't see the big picture of what your code is doing quickly, then its not readable. Comments should be used sparingly, identifier names and method implementations should strive to be so readable that comments are not necessary. understandable: you should always consider if your code "understandable to a 10 year old programmer?". clean: precise and to the point (no extra fuss...with in reason of course), one liners if it lends to higher level of readability and understanding. efficient: a corner stone of good programming, short to the point, and the use of time (run time) and space (memory) efficiency. CODE FORMAT Each class listed must be given in the following order: 1. constants (grouped/alphabetical order) 2. data fields (grouped/alphabetical order) 3. constructors in order of increasing parameters) 4. methods (alphabetical order) 5. inner classes (alphabetical order) Interfaces About Objective: To demonstrate the use of interfaces using within a multi-class program. You should assume that all data is encapsulated. Classes for Use You may ONLY use the classes in the Java API listed below or in the starter code. All imported classes or interfaces must be spelled out by name, DO NOT use the wildcard feature import java.awt.Color; import java.awt.Graphics; Test Interfaces Instructions: Within the exercise package of your repository folder, you are given starter code. The class "Display" is a basic GUI window "Frame" to help you draw the graphics. Update/Create the classes in the exercise package to display the information described below. Task List Update the TODO's within the Main Program and place results in your lab report. Create the interface "Drawable" with methods "draw" and "move" described below. Create the interface "Fillable" with constant AQUA and methods, "draw" and "fill" described below. Create the class "Circles" that will be used to implement the methods of "Drawable" and "Fillable". create the data fields color, pen, x and y, which represents the color, graphics object and top left x and y coordinates respectively. See below. . Note: The data fields should be encapsulated, so as to prevent other programs changing its data. o create the methods described in the "Circles" class below. Create in your main program a "Drawable" and "Fillable" object using the "Circles" objects. Each object must take a graphics object object as an argument. Your graphics object reference is "pen". use the method "testDrawable" to create circles of a "Drawable" Type o move across by (50, 0) and draw YELLOW circles o move down by (0, 100) and draw RED circles o move down by (0, 100) and draw Fillable AQUA circles use the method "testFillable" to create circles of a "Fillable" Type use setLocation to set the location of your Fillable object to (0,0) draw "Fillable" RED, WHITE and BLUE circles using fillo draw Circles using draw() NOTE: Feel free to adjust coordinates above to better suit the position in your GUI window. place SCREEN SHOTS of output, a brief summary and descriptions in your lab report PDF. github-classroom Initial commit Display.java Main Program.java pemain lab02-zhanpengouyang /src/exercise / Display.java / Jump to github-classroom Initial commit 81 contributor 45 lines (34 sloc) 1.02 KB 1 package exercise; 2 3 4 import java.awt.Color; import java.awt.Graphics; import javax.swing. JFrame; 5 6 7 public class Display { 8 9 19 public static final int WIDTH = 500; public static final int HEIGHT = 400; public static final int X_TOP 200; public static final int Y_TOP = 100; 11 12 14 public JFrame frame; //Display Window 15 public Display() { this (WIDTH, HEIGHT); } 18 19 20 21 22 23 public Display(int width, int height) { frame = new JFrame(); frame.setTitle("Drawing Window"); frame.setSize(width, height); frame.setLocation (X_TOP, Y_TOP); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } 24 25 26 27 28 29 39 public Graphics getGraphics() { return frame.getContentPane().getGraphics(); } 31 32 33 34 public void clear(){ frame.repaint(); } 35 36 28 29 public Graphics getGraphics() { return frame.getContentPane().getGraphics(); } 31 32 33 public void clear() { frame.repaint(); } 35 37 38 public void setBackground(Color ) { frame.getContentPane().setBackground(); } 39 41 public void pause(int milliseconds) throws Exception { Thread. sleep(milliseconds); } 43 } pe main lab02-zhanpengouyang /src/ exercise / Main Program.java / Jump to github-classroom Initial commit Latest commi 221 contributor 50 lines (30 sloc) 1.25 KB 1 package exercise; 3 import java.awt.Color; import java.awt.Graphics; 4 5 public class MainProgram { 6 7 public static void testDrawable (Display display, Drawable circles) throws Exception { 8 9 13 // TODO : Move to location and draw Yellow Circles 21 12 // TODO : Move to location and draw RED Circles 23 14 // TODO : Move to location and draw Circles with Fillable AQUA 15 16 display.pause (500); 17 } 18 public static void testFillable(Display display, Fillable filledCircles) throws Exception { 20 //TODO: Set Location back to location (50, 50) 22 23 display. pause (500); 24 25 // TODO : Draw fillable RED, WHITE and BLUE Circles 26 27 // TODO : Draw circles with Fillable AQUA Color display.pause (500); 28 29 } 39 31 public static void main(String[] args) throws Exception 32 33 Display display = new Display (600, 500); display.setBackground (Color. DARK_GRAY); 35 36 1/ Get Graphics Pen Object for Drawing in Window Graphics pen = display.getGraphics(); 37 38 38 39 // TODO : Create Circles of a Drawable Type 41 // TODO : Draw Drawable Circies 43 // clear display if needed (uncomment) // display.clear(); 44 45 46 // TODO : Create Circles of a Fillable Type 47 48 // TODO : Draw Fillable Circles 49 59

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_2

Step: 3

blur-text-image_3

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

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions

Question

1.. Identify questions to guide decisions about resume content.

Answered: 1 week ago