$30.00
Order Nowjar
file before, this Self-Learning Module from CS1021 should help.Prior to smartphones and tablets, parents resorted to flattened wood pulp and sticks of colored wax to occupy their kids’ attention. One popular App for paper and crayons was called “Connect the Dots” or “Dot to Dot.” The “screen” consisted of a collection of numbered dots. The user was required to draw lines between consecutive dots. If the user worked the App correctly, a piece of art emerged. In this assignment you will build the foundation for a multi-week project. The subsequent two laboratory assignments will build on this one, allowing you to improve your initial submission, based on feedback from your instructor, and expand the program’s functionality.
You must create a program that will read a picture from a .dot
file and graphically display the picture stored in the file.
Your program must have two menu items:
.dot
file and displays the dots in the file. In addition, it connects neighboring dots with lines (including connecting the last dot back to the first dot).Platform.exit()
)Note that the Number of Dots menu item is not required for this lab but will be an added requirement in lab 2.
The Draw menu items should only be active when a picture has been loaded.
All of your classes should be placed in a package whose name matches your MSOE username.
You must implement two classes:
Dot
— Represents a dot in the picture.Picture
— Holds a list of Dots
that describe a picture.The Picture
class must implement the following methods:
void load(Path path)
— Loads all of the dots from a .dot
file.void drawDots(Canvas canvas)
— Draws each dot in the picture onto the canvas.void drawLines(Canvas canvas)
— Draws lines between all neighboring dots in the picture on the canvas..dot
File FormatYour program must be able to read dot files that contain a list of dots. The file is formatted such that each dot is on a separate line. A dot consists of a horizontal and vertical component separated by a comma. Each component is a floating point value between zero and one. For example, square.dot
looks like this:
0.1, 0.1
0.1,0.9
0.9,0.9
0.9, 0.1
There are several .dot
files in the data
folder for the repository.
A dot can be drawn on a Canvas
by first obtaining the GraphicsContext
and then calling the fillOval()
method. Be sure to set an appropriate fill color and center the dot over its coordinate location.
Lines should be drawn between all neighboring dots, including a line from the last dot back to the first dot. The lines can be drawn on a Canvas
by first obtaining the GraphicsContext
and then creating a path. To do this:
beginPath()
moveTo()
lineTo()
closePath()
stroke()
to draw the pathThere are several situations that could cause your program to throw an exception. For example, if the file is not found, cannot be opened, or contains incorrectly formatted data, it is likely that an exception will be thrown. In these cases, the program should display an useful message in an Alert
.
Ambitious students may wish to:
lineTo()
with quadraticCurveTo()
or bezierCurveTo()
.WhatsApp us