Computer Science Question

I have two java assignments and they are pretty easy actually but I just don’t have time to focus on it right now.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

I am attaching the pdf with all the as well as the zip and rubric doc. I am going to attach project 2 rubric and .txt input file after this is assigned since I attached the maximum number of files.

Please let me know if you need anything.

The first programming project involves extending the Java skeleton program that it is provided in
the attached .zip file. That skeleton program displays a scene of graphic images contained in a
scene definition file. The grammar for that scene definition file is shown below:
scene → SCENE IDENTIFIER number_list images END ‘.’
images → image images | image
image → right_triangle | rectangle
right_triangle →
RIGHT_TRIANGLE COLOR number_list AT number_list HEIGHT NUMBER WIDTH
NUMBER ‘;’
rectangle →
RECTANGLE_ COLOR number_list AT number_list HEIGHT NUMBER WIDTH
NUMBER ‘;’
number_list → ‘(‘ numbers ‘)’
numbers → NUMBER | NUMBER ‘,’ numbers
In the above grammar, terminal symbols are upper case names or character literals shown in blue
and nonterminal symbols are lower case names shown in red. EBNF metacharacters are shown in
black. Tokens can be separated by any number of spaces. Identifiers and keywords are strings of
alphabetic characters. Identifiers are case sensitive. Numbers are unsigned integers.
That program reads in the scene definition file that defines the image objects in a scene and
creates those objects, inserts them into the scene and displays that scene.
You are to modify the program so that it will parse and display the additional images defined by
the expanded grammar shown below with the additions to the grammar highlighted in yellow:
scene → SCENE IDENTIFIER number_list images END ‘.’
images → image images | image
image →
right_triangle | rectangle | parallelogram | regular_polygon | isosceles
| text
right_triangle →
RIGHT_TRIANGLE COLOR number_list AT number_list HEIGHT NUMBER WIDTH
NUMBER ‘;’
rectangle →
RECTANGLE_ COLOR number_list AT number_list HEIGHT NUMBER WIDTH
NUMBER ‘;’
parallelogram →
PARALLELOGRAM COLOR number_list AT number_list number_list OFFSET
NUMBER ‘;’
regular_polygon →
REGULAR_POLYGON COLOR number_list AT number_list SIDES NUMBER RADIUS
NUMBER ‘;’
isosceles →
ISOSCELES COLOR number_list AT number_list HEIGHT NUMBER WIDTH
NUMBER ‘;’
text →
TEXT COLOR number_list AT number_list STRING ‘;’
number_list → ‘(‘ numbers ‘)’
numbers → NUMBER | NUMBER ‘,’ numbers
The UML diagram for the whole project is shown below:
The classes shown in black are included in the skeleton project. You must complete the project
by writing those classes shown in red, modifying the Parser class so that it will parse the
expanded grammar, modifying the Lexer class to handle string tokens, and modifying the
Tokens enumerated type to add all the new tokens.. Below is a description of each of the five
classes that you must write:
The Text class must contain a constructor that is supplied the color that defines the text color, a
point that specifies the text location and a string containing the text to be displayed. It must also
contain a draw function because it is extends the abstract class Image. The draw function must
draw the text using the method drawString in Graphics class.
The SolidPolygon class must contain a constructor that is passed the number of vertices in the
polygon and its color. It must define the method drawPolygon because it is extends the abstract
class Polygon_. It should call the fillPolygon method of the Graphics class to draw a solid
polygon.
The IsoscelesTriangle class must have a constructor that is supplied the color of the triangle,
a point that specifies the location of the top vertex, and the height and width of the triangle. It
must allocate the arrays of x and y coordinates that defines the triangle and it must compute their
values.
The Parallelogram class must have a constructor that is supplied the color of the parallelogram,
two points that specifies the location of the upper left and lower right vertices in addition to
an x offset value that specifies the x distance between the upper and lower left vertices. It must
allocate the arrays of x and y coordinates that defines the parallelogram and it must compute their
values.
The RegularPolygon class must contain a constructor that is supplied the color of the polygon,
the number of sides, a point that specifies the location of its center, and the radius, which defines
the distance between the center and each of the vertices. It must allocate the arrays of x and y
coordinates that defines the regular polygon and it must compute their values.
Below is a sample of a scene definition file that would provide input to the program:
Scene Polygons (500, 500)
RightTriangle Color (255, 0, 0) at (50, 30) Height 100 Width 300;
Rectangle Color (0, 128, 255) at (100, 100) Height 200 Width 100;
Isosceles Color (255, 0, 0) at (120, 120) Height 100 Width 200;
Parallelogram Color (0, 0, 255) at (340, 50) (440, 120) Offset 30;
RegularPolygon Color(255, 0, 255) at (300, 300) Sides 6 Radius 80;
Text Color(0, 0, 0) at (400, 200) “Hello World”;
End.
Notice that the token names are all upper case and may contain underscores whereas the
corresponding lexemes at in title case without underscores. For example the token
RIGHT_TRIANGLE has lexeme RightTriangle. The lexical analyzer in the skeleton handles the
necessary conversion. Shown below is the scene that should be produced when the program is
provided with the above scene definition.
The deliverables for this project include the following:
1. A .zip file containing all the source code correctly implementing all required
functionality.
a. All the .java files provided in the skeleton should included regardless of whether
they required any changes
b. All new files must include a header with the student name, date, project and a
description of what the file contains
c. All modified files must include a header with the same information
2. A Word or PDF file that contains the following:
a. A discussion of how you approached the project
b. A test plan that contains test cases that include all additional images and test any
new functionality. For each test case, the output produced should be included.
c. A discussion of lessons learned from the project and any improvements that could
be made
Criteria
Meets
Does Not Meet
Functionality
175 points
Parser parses all new image specifications
correctly (50)
0 points
Parser does not parse all new image
specifications correctly (0)
Text class correctly implemented (25)
Text class not correctly implemented
(0)
SolidPolygon class correctly implemented
(25)
IsoscelesTriangle class correctly
implemented (25)
Parallelogram class correctly implemented
(25)
RegularPolygon class correctly
implemented (25)
Test Plan
45 points
Test cases include all 5 new images (30)
Test cases include syntactically incorrect
scene files (15)
SolidPolygon class not correctly
implemented (0)
IsoscelesTriangle class not orrectly
implemented (0)
Parallelogram class not correctly
implemented (0)
RegularPolygon class not correctly
implemented (0)
0 points
Test cases do not include all 5 new imag
(0)
Test cases do not include syntactically
incorrect scene files (0)
Criteria
Meets
Does Not Meet
Documentation
50 points
Discussion of approach included (20)
0 points
Discussion of approach not included (0)
Lessons learned included (20)
Lessons learned not included (0)
Comment blocks with student name,
project, date and code description included
in each file (10)
Comment blocks with student name,
project, date and code description not
included in each file (0)
Total
Score of Project 1,
/ 270
The second project involves completing and extending the C++ program that evaluates
statements of an expression language contained in the module 3 case study in the week 5 module
reading.
The skeleton code for this project is attached. It differs slightly from the what is provided in the
case study. The code in the case study allows only one expression to be input from the keyboard
whereas the code in the attached skeleton accepts input from a file named input.txt. That file
contains one statement per line.
The statements of that expression language consist of an arithmetic expression followed by a list
of assignments. Assignments are separated from the expression and each other by commas. A
semicolon terminates the expression. The arithmetic expressions are fully parenthesized infix
expressions containing integer literals and variables. The syntax of a single input file line is
described grammar below:
statement → expression ‘,’ assignments ‘;’
expression → ‘(‘
operand operator operand ‘)’
operator → ‘+’ | ‘-‘
operand → literal | variable | expression
assignments → assignments ‘,’ assignment | assignment
assignment → variable ‘=’ literal
In the above grammar, terminal symbols are upper case names or character literals shown in blue
and nonterminal symbols are lower case names shown in red. EBNF metacharacters are shown in
black. Tokens can be separated by any number of spaces.
Tokens can be separated by any number of spaces. Variable names begin with an alphabetic
character, followed by any number of alphanumeric characters. Variable names are case
sensitive. The regular expressions defining the variables and literal tokens are the following:
variable
[a-zA-Z][a-zA-Z0-9]*
literal
[0-9]+
The program reads in the arithmetic expression and encodes the expression as a binary tree. After
the expression has been read in, the variable assignments are read in and the variables and their
values of the variables are placed into the symbol table. Finally the expression is evaluated
recursively.
Your first task is to modify the program so that it will parse additional types of expressions
defined by the expanded grammar shown below with the additions to the grammar highlighted in
yellow:
statement → expression ‘,’ assignments ‘;’
expression → ‘(‘
expressions ‘)’
expressions → unary_expression | binary_expression | ternary_expression |
quaternary_expression | operand
unary_expression → expression ‘~’
binary_expression
→ expression binary_operator expression
binary_operator → ‘+’ | ‘-‘ | ‘*’ | ‘/’ | ‘%’ | ‘^’ | ” | ‘&’
ternary_expression → expression ‘?’ expression expression
quaternary_expression → expression ‘#’ expression expression expression
operand → literal | variable | expression
assignments → assignments ‘,’ assignment | assignment
assignment → variable ‘=’ literal
The semantics of the additional binary arithmetic operators are as follows:
* Multiplication
/ Division
% Remainder
^ Exponentiation
Although two of the three additional binary operators are customarily relational operators in
most languages, that is not true in this language. The semantics of all three of those operators are
as follows:
< Minimum (Evaluates to the minimum of the left and right operand) > Maximum (Evaluates to the maximum of the left and right operand)
& Average (Evaluates to the average of the left and right operand)
The single unary operator ~ is the negation operator. Unlike the unary minus in most languages,
it is a postfix operator rather than a prefix one.
The single ternary operator ? is the conditional expression operator. Unlike the conditional
expression operator in C++ and Java, no colon separates the second and third operands. This
expression is evaluated as follows. If the expression to the left of the operator ? is not 0, the
value of the expression is the value of the first expression after the operator ?. If it is 0, the value
of the expression is the value of the second expression after the operator ?.
The single quaternary operator # is a variation of the typical conditional expression operator.
Like the ternary conditional expression operator, the remaining three operands are delimited only
by whitespace. This expression is evaluated as follows. If the expression to the left of the
operator # is less than 0, the value of the expression is the value of the first expression after the
operator #. If it is equal to 0, the value of the expression is the value of the second expression
after the operator #. If it is greater than 0, the value of the expression is the value of the third
expression after the operator #.
The second task is to modifier the variable token so that underscores are permitted in all but the
first character and modify the literal token so that it accepts unsigned floating point literals.
Assignments also should be modified to allow assignment to values that are should also floating
point rather than just integers.
The final task is to make the following modifications:



The symbol table should be initialized before each statement is evaluated, so that
variables that are reused do not contain the value from a previous statement
Statements containing uninitialized variables should be reported as an error
A variable initialized more than once in a statement should be reported as an error
(Creating an exception class to accommodate this error and the previous one is the
recommended approach)
You may assume that all input is syntactically correct. No checks for syntax errors is required.
Each new class must be in a separate .h and .cpp pair of files. If all the functions in a class are
one line functions, they can be implemented inline in .h file and the .cpp file can be omitted.
The deliverables for this project include the following:
1. A .zip file containing all the source code correctly implementing all required
functionality.
a. All the .h and .cpp files provided in the skeleton should included regardless of
whether they required any changes
b. All new files must include a header with the student name, date, project and a
description of what the file contains
c. All modified files must include a header with the same information
2. A Word or PDF file that contains the following:
a. A discussion of how you approached the project
b. A test plan that contains test cases that include all additional images and test any
new functionality. For each test case, the output produced should be included.
c. A discussion of lessons learned from the project and any improvements that could
be made

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Order a unique copy of this paper

600 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
Top Academic Writers Ready to Help
with Your Research Proposal

Order your essay today and save 25% with the discount code GREEN