: Make a File Reader For this step, you will only need to modify, and thus focus on, the following class: • ReadShapeFile.java Figure 1: Empty Window with a Title: Shape Booooi- iinggg Frame You will also need to look at only the constructors of the following classes: • Circle.java • Oval.java Pretend the rest of the code does not exist. This is how we break large programs into smaller components that a human can understand and work with. It’s also how the rest of engineering works as well. Think about how the parts of a car engine are compartmentalised nicely into components. You don’t need to hold the entire functionality of the engine in your head at one time – just the component you are working on and how it interfaces with the rest of the system. It is very important that you only modify code in the files you are asked to modify. If your development environment suggests to change code outside these files don’t do it – even if it makes things magically compile and the red text disappears. Please assume the mistake is in the code you have just written and not in the code supplied. It is important you do not modify code supplied (except where indicated) because this could cause Autograder to fail to properly read your submission. In the first step of the assignment, you’ll create a file reader that reads the shape files supplied to you. Each line of the shape file specifies a shape. The format of this line differs depending on the shape to be created. Fortunately, the first entry of the line always indicates what shape is to be created from this input. For exam- ple, to create a circle: circle To create an Oval, the line in the file would be as fol- lows: oval All these entries are on a single line of the file. I have broken them into two lines for readability. Angular brackets are placeholders for numbers/values as fol- lows: • - time in milliseconds since the start of the program after which the shape is inserted • - The starting position of the shape in the plane

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

2.2 Step 1: Make a File Reader
For this step, you will only need to modify, and thus
focus on, the following class:
• ReadShapeFile.java
Figure 1: Empty Window with a Title: Shape Booooi-
iinggg Frame
You will also need to look at only the constructors of
the following classes:
• Circle.java
• Oval.java
Pretend the rest of the code does not exist. This is how
we break large programs into smaller components that
a human can understand and work with. It’s also how
the rest of engineering works as well. Think about how
the parts of a car engine are compartmentalised nicely
into components. You don’t need to hold the entire
functionality of the engine in your head at one time
– just the component you are working on and how it
interfaces with the rest of the system.
It is very important that you only modify code in the
files you are asked to modify. If your development
environment suggests to change code outside these
files don’t do it – even if it makes things magically
compile and the red text disappears. Please assume the
mistake is in the code you have just written and not in
the code supplied. It is important you do not modify
code supplied (except where indicated) because this
could cause Autograder to fail to properly read your
submission.
In the first step of the assignment, you’ll create a file reader that reads the shape files supplied to you. Each
line of the shape file specifies a shape. The format of
this line differs depending on the shape to be created.
Fortunately, the first entry of the line always indicates
what shape is to be created from this input. For exam-
ple, to create a circle:
circle <insertion time> <px> <py> <vx> <vy>
<filled?> <diameter> <r> <g> <b>
To create an Oval, the line in the file would be as fol-
lows:
oval <insertion time> <px> <py> <vx> <vy>
<filled?> <width> <height> <r> <g> <b>
All these entries are on a single line of the file. I have
broken them into two lines for readability. Angular
brackets are placeholders for numbers/values as fol-
lows:
• <insertion time> - time in milliseconds
since the start of the program after which the
shape is inserted
• <px> <py> - The starting position of the shape
in the plane
• <vx> <vy> - The velocity of the shape as a vec-
tor
• <filled?> - True if the shape is filled and false
otherwise
• <r> <g> <b> - The colour of the shape
For circle only, you have:
• <diameter> - the diameter of the circle
For oval only, you have:
• <width> <height> - the width and height
(major and minor axis) of the oval.
You cannot modify the file format in this assignment.
These files will be automatically on autograder and if
you modify file format your program marking will fail.
In ReadShapeFile.java, write methods to read
files consisting of circles and ovals only. Also, you
can assume that the file is sorted by insertion time.
This means that the lines of the file must be in increas-
ing <insertion time> order. I would start by trying to read a single line of the file
followed by multiple lines, printing them to the screen
to ensure you are reading the data correctly. Then, cre-
ate instances of the shape objects and print them out.
You can do this by calling the toString() method
that has already been given to you.
If the file does not exist, quit the program grace-
fully and output Could not find <filename>
to the screen (standard out) with <filename> re-
placed by the file that will not open. However, you
can assume that each line of the file has the cor-
rect syntax. To test your code, please try to run the
TwoRedCircles.txt file. Start by printing out
each line your read to the terminal to make sure you
are reading the data correctly. Then, create instances
of the objects and use the toString() method to
print out the object and make sure that it is being cre-
ated correctly.

 

import javafx.scene.paint.Color;
import java.io.*;
import java.util.Scanner;
public class ReadShapeFile {
// TODO: YoU will likely need to write four methods here. One method to
// construct each shape
// given the Scanner passed as a parameter. I would suggest static
// methods in this case.
/** Reads the data file used by the program and returns the constructed queue ...*)
private static Queue<ClosedShape> readLineByLine(Scanner in) {
Queue<ClosedShape> shapeQueue = new Queve<ClosedShape>();
//read in the shape files and place them on the Queue
//Right now, returning an empty Queue.
You need to change this.
return shapeQueue;
}
Transcribed Image Text:import javafx.scene.paint.Color; import java.io.*; import java.util.Scanner; public class ReadShapeFile { // TODO: YoU will likely need to write four methods here. One method to // construct each shape // given the Scanner passed as a parameter. I would suggest static // methods in this case. /** Reads the data file used by the program and returns the constructed queue ...*) private static Queue<ClosedShape> readLineByLine(Scanner in) { Queue<ClosedShape> shapeQueue = new Queve<ClosedShape>(); //read in the shape files and place them on the Queue //Right now, returning an empty Queue. You need to change this. return shapeQueue; }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education