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...


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



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
- The velocity of the shape as a vec-
tor
- True if the shape is filled and false
otherwise


- The colour of the shape
For circle only, you have:
- the diameter of the circle
For oval only, you have:
- 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 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
to the screen (standard out) with 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;<br>import java.io.*;<br>import java.util.Scanner;<br>public class ReadShapeFile {<br>// TODO: YoU will likely need to write four methods here. One method to<br>// construct each shape<br>// given the Scanner passed as a parameter. I would suggest static<br>// methods in this case.<br>/** Reads the data file used by the program and returns the constructed queue ...*)<br>private static Queue<ClosedShape> readLineByLine(Scanner in) {<br>Queue<ClosedShape> shapeQueue = new Queve<ClosedShape>();<br>//read in the shape files and place them on the Queue<br>//Right now, returning an empty Queue.<br>You need to change this.<br>return shapeQueue;<br>}<br>

Extracted 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 readLineByLine(Scanner in) { Queue shapeQueue = new Queve(); //read in the shape files and place them on the Queue //Right now, returning an empty Queue. You need to change this. return shapeQueue; }


Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here