
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Topic Video
Question
thumb_up100%
Using java
Import java.util
Import java.scanner
Import java.io

Transcribed Image Text:The purpose of this assignment is to practice OOP with Decisions, Loops, Arrays and ArrayLists, Input/Output
Files, Class design, Interfaces, Polymorphism and Exception Handling. Create a NetBeans project named
HW3_Yourld. Develop classes for the required solutions.
Important: Apply good programming practices:
Provide API documentation comments for your class(s), class constructor(s) and method(s) using the
Java standard form for documentation comments discussed in this course.
Use meaningful variable and constant names.
Show your name, university id and section number as a comment at the start of each class.
- Submit to Moodle the compressed file of your project.
Problem:
In this assignment, you should study and program an application for drawing graphic objects using object-
oriented programming concepts. There are several graphic objects that can be drawn however for the purpose
of this project your application will be able to draw only three types: lines, rectangles and parallelograms.
Write a Java application that draws different graphic objects on a single canvas. Your application should be able
to draw lines, rectangles and parallelograms. The application should allow the user to move these objects to
specific location (x, y), and fill the objects if needed. In this assignment you should not use any of the graphics
packages provided by java, instead you should create your own drawings by using the System.out printing
feature.
Specifications:
• Each graphic object is drawn in a specific location (x, y) (the left top most corner of the object).
• A line object has a length and can be moved, and drawn.
A rectangle object has width and height and can be moved, drawn and filled or not with a specific
character as shown in the Figure of the sample run.
A parallelogram also has a defined base and height and can be moved, drawn, and filled or not with a
specific character.
All your drawing must be on one canvas. You can assume that a canvas is a two-dimensional array of
characters, representing the pixels of the canvas, and you just need to fill the cells af this matrix as
needed by each created object. For instance, for a canvas of size 15 x 20, the result of the pseudocode
for Figure I will produce the following content in the canvas array.
For example, the following pseudocode will create a parallelogram of base 8 and height 6, then it will be moved
to position (5, 2), filled with "+", and then it will be drawn on the canvas. After that, a line object of length 15
is drawn starting at (2, 4). The output of the pseudocode is shown in Figure 1.
parallelogran- new Parallelogram (8, 6)
parallelogran. movero (5,2)
parallelogran, setFL1led(true)
parallelogran, setFillingsynbol ('+')
parallelogran. draw (canvas)
++++++++
+++++
+キキキキ
line - new Line (2, 4, 151
line.draw(canvas)
show (canvas)
+++++
Figure 1: Output of the pseudocode example
Your program should read the specifications of graphic objects from a text File provided by the user using the
command line. Each graphic object starts with a letter indicating the type of the object (L: line, R: rectangle,
or P: parallelogram), followed by the properties of the object (e.g. position (optional), length of a line, width
and length for a rectangle, or base and height for a parallelogram). The next lines will define any operations
applied to that object (e.g. moveTo 2 5, filled yes, filling +, draw). Each object description is terminated by a
dashed line as shown in the sample below (Figure 2).
Your program should read the details of cach object, apply the requested operations, handle any exceptions
might be raised, and finally show the entire canvas that has all the drawn objects.
-e objects.txt
L 15
mavete 2 4
draw
maveta s 2
+++++
R 20 355
filled yes
itting
draw
+++++
+++++
+キ+ャ
+++++
P 10 6
draw
aveto 24 1
draw
P 15 15 53
tilled yes
draw
R 74
tilled no
moveTo 5 1e
draw
*****
*****
中キキ
L327
Figure 2: Sample Input file and the drawing corresponding to its content.

Transcribed Image Text:L 15
moveTo 2 4
draw
R 20 3 5 5
filled yes
filling +
draw
P 10 6
draw
moveTo 24 11
draw
P 15 15 5 3
filled yes
draw
R 7 4
filled no
moveTo 5 10
draw
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}arrow_forwardimport java.util.Scanner; public class CircleAndSphereWhileLoop{ public static final double MAX_RADIUS = 500.0; public static void main(String[] args) { Scanner in = new Scanner(System.in); // Step 2: Read a double value as radius using prompt // "Enter the radius (between 0.0 and 500.0, exclusive): " // Step 3: While the input radius is not in the ragne (0.0, 500.0) // Display a message on one line (ssuming input value -1) // "The input number -1.00 is out of range." // Read a double value as radius using the same promt double circumference = 2 * Math.PI * radius; double area = Math.PI * radius * radius; double surfaceArea = 4 * Math.PI * Math.pow(radius, 2); double volume = (4 / 3.0) * Math.PI * Math.pow(radius, 3); // Step 4: Display the radius, circle circumference, circle area, // sphere surface area, and…arrow_forwardVM obfuscation transforms the original program by converting native instructions such as ADD, MOV, XOR, JMP, and so on into Javarepresentations of the same methods Group of answer choices True falsearrow_forward
- import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(" "); String s1 = sc.nextLine(); System.out.print(""); String s2 = sc.nextLine(); int minLen = Math.min(s1.length(), s2.length()); int matchCount = 0; for (int i = 0; i < minLen; i++) { if (s1.charAt(i) == s2.charAt(i)) { matchCount++; } } if (matchCount == 1) { System.out.println("1 character matches"); } else { System.out.println(matchCount + " characters match"); } sc.close(); }}arrow_forwardDevelop a Java program that creates a JSON object that represents a car, including properties such as make, model, year, and color. Develop a Java program that can convert an XML document to a JSON object. Develop a Java program that can convert JSON data to XML format.arrow_forward//********************************************************************//EvenOdd.java Java Foundations////Demonstrates the use of the JOptionPane class.//******************************************************************** import javax.swing.JOptionPane; public class EvenOdd{//-----------------------------------------------------------------// Determines if the value input by the user is even or odd.// Uses multiple dialog boxes for user interaction.//-----------------------------------------------------------------public static void main (String[] args){String numStr, result;int num, again; do {numStr = JOptionPane.showInputDialog ("Enter an integer: "); num = Integer.parseInt(numStr); result = "That number is " + ((num%2 == 0) ? "even" : "odd"); JOptionPane.showMessageDialog (null, result); again = JOptionPane.showConfirmDialog (null, "Do Another?");}while (again == JOptionPane.YES_OPTION);System.out.println("here");}}arrow_forward
- Convert the following java code to C++ //LabProgram.javaimport java.util.Scanner;public class LabProgram {public static void main(String[] args) {//defining a Scanner to read input from the userScanner input = new Scanner(System.in);//reading the value for Nint N = input.nextInt();//creating a 1xN matrixint[] m1 = new int[N];//creating an NxN matrixint[][] m2 = new int[N][N];//creating a 1xN matrix to store the resultint[] result = new int[N];//looping and reading N integers into m1for (int i = 0; i < N; i++) {m1[i] = input.nextInt();}//looping from 0 to N-1for (int i = 0; i < N; i++) {//looping from 0 to N-1for (int j = 0; j < N; j++) {//reading an integer and storing it into m2 at position i,jm2[i][j] = input.nextInt();}}//multiply m1 and m2, store result in result//looping from 0 to N-1for (int i = 0; i < N; i++) {//looping from 0 to N-1for (int j = 0; j < N; j++) {//multiplying value at index j in m1 with value at j,i in m2, adding to current value at index i// on…arrow_forwardJava programming using do-while looparrow_forwardjava: Explain the 3 methods used to make Deep Copies.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education