Question: 8 . 4 8 Program 1 2 : QR Code class Instructor note: Read about command - line arguments. We will show you in class
Program : QR Code class
Instructor note:
Read about commandline arguments. We will show you in class how to use them.
To set commandline arguments in IntelliJ IDE. Modify the area called "Program arguments" outlined in the image with blue
To set commandline arguments in Eclipse IDE:
Step : Select the Run tab from the top menu, then Run Configurations...
Step : Specify the Program Arguments in the Arguments Tab.
Step : Click on the Run button.
Introduction
This lab uses things you learned in your introductory programming class. Some of those things are:
constants
random numbers
overloaded methods
passingreturning arrays
filling and printing a onedimensional array
filling and printing a twodimensional array
Just for fun, we've included a GUI to visualize your QR code! Get it from the Program Assignment on Canvas.
Specifications
You will create a class QRCode that fills a grid with values that can be interpreted to visualize a QRCode image. This is not a true QRCode but a pattern similar to one.
Required elements
QRCode class methods are instance methods.
Your program will contain a main method that creates an instance of QRCode and calls its methods such that the result output is a grid dim x dim with Finder values in the upper left, lower left, and upper right corners.
The dimension for the grid and the seed for the Random object must be passed in from the command line.
If two arguments are not passed in from the command line, your program should use constants defined below:
DEFAULTDIMENSION
DEFAULTSEED
Methods that return a value must pass unit tests that will not be made available for view, that is those methods should be thoroughly tested by you prior to submitting your program.
Only the print methods may have output to the console.
Class members must conform to the UML diagram below:
Class Name
QRCode
Private Variables
grid : int
Public methods
createPatterndim : int, seed : int : int
setGriddim : int, pattern : int : void
getGrid : int
setFinderxPos : int, yPos : int : void
fillSquarestartX : int, startY : int, width : int, color: int : void possible helper method
addFindersdimension : int : void
print : void
printpattern : int : void
printmatrix : int : void
Method specifications
createPattern returns a new onedimensional array the size of dim squared. The array should be filled with random s and s which are generated by a java.util.Random object constructed with the given seed.
setGrid takes in the dimension dim and instantiates a twodimensional array size of dim by dim. The grid is then filled row by row from the pattern provided by the onedimensional pattern passed in
getGrid returns a representation of the grid member.
addFinders calls setFinder for each of the three finders upper left, upper right, lower left positions
setFinder calls fillSquare for each borderbox which will overwrite the existing grid with the Finder pattern described here, placing a finder in each of the upper left, upper right, and lower left corners of the grid. If a grid is null, it returns null. The upper left corner of a Finder pattern is given by the parameters xPos and yPos which are the column and row, respectively, in the class member grid.
The output border is two pixels in width. All values are set to WHITE in the GUI
The next inner border is two pixels in width. All values are set to BLACK in the GUI
The next inner border is two pixels in width. All values are set to WHITE in the GUI
The innermost box is x pixels. All values are set to BLACK in the GUI
fillSquare sets the specified color of a square given the dimension length and starting coordinates of the upper left corner of the square area. The border width is passed in but not used oops
print outputs the class member grid as a twodimensional grid with no spaces between values in a row
printpattern outputs the onedimensional pattern passed a a parameter as a twodimensional grid with no spaces between values in a row
printmatrix outputs the twodimensional matrix passed as a parameter row by row with no spaces between values in a row
Testing
Things to test for are the correct number of command line arguments, a null pointer passed in if a pattern, grid, or matrix parameter structure has not actually been created yet, and the values of the Finder are as expected, among other things you can thing of Using the visualization testing program we provided will help verify the Finder values, plus you can pick out the pattern in the output too.
Here is an example of the code with the GUI: QR code with default values
Output with default values:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
