Java object oriented programming (freshman level)

Java object oriented programming (freshman level)

Place a Bid
Amount you will charge($) A 10% transaction fee will be added to your bid
Submit
Bids Placed by Scholars
No Bids Placed Yet, Consider Upgrading Your Project
Actions
Bookmark Project
Details
Posted By View Student Profile
Subject Computer
Deadline (Pacific Time) 03/19/2017 08:58 pm
Budget $30-$100
I have attached 2 assignments and 3 files(a04 solution, a05, and a06). ao5 builds off of a04 solution, and a06 builds off of a05 when complete. If I am pleased with
the quality of the work I will be seeking a weekly arrangement for up to 6 weeks. I have 2 assignments due this Sunday at 11:59 CST, then will have an assignment due
each sunday following that (with exceptions)

Â

Quality/speed of work is more important than price, so I am willing to negotiate.

fastest way to contact me is at cshomeworkacct@gmail.com
File #1
File #2
File #3

Assignment 5
Calculator Framework due on March 5
Objectives: frameworks, inheritance, trees, tree traversal, visitor design pattern
This is a pair assignment. You can solve the assignment alone or in a team of two. Do not
copy code from other students or teams!
Background: In Assignments 2 – 4, we have built a calculator framework. The current calculator
instances compute as the calculator input is processed. However, instead of computing immediately,
we could also represent the calculation in form of an expression tree. Consider the figures below
representing the input in tree format. Expression trees represent computations in form of a tree.
The tree consists of interior nodes that represent operations, and leaf nodes that represent values.
(a) represents (3 + 4) ∗ 5 (b) represents 3 + 4 + 5
In order to compute an expression at the root of the tree, we can compute the result of its
subexpressions. For example, Fig. 1a represents the an expression tree for the input (3 + 4) ∗ 4.
The last computation in this tree is the multiplication. Before it can be carried out, we need to
compute the results of its subtrees. The left-hand subtree is an add operation. In order to compute
the result for add, we “compute” the result of its sub-expressions. Its subexpression are two values,
which are leaf-nodes in the tree. Their computation just yields their values, 3 and 4 respectively.
Then, we can carry out the add, yielding 7. Before we can compute the multiplication, the result
for its right-hand branch has to be computed. Its computation yields 4. Hence the result will yield
28. Similarly the result can be computed for the right-hand example.
For this assignment you can continue your own framework, or you start from the model solution
for Assignment 4. The model solution also includes classes that represent operations and values for
the expression tree. The UML diagram of this classes is depicted in Fig. 2.
Tasks
• Build a calculator that returns the root of an expression tree (instead of performing the calculation
immediately). To this end, implement a class ExprTreeTokenizer that parses doubles
and returns the content in an object of type Value. Second, a class ExprTreeCalculator will
be needed that creates the corresponding tokenizer object. No modification of the calculator
base classes should be required.
1
Figure 2: UML showing expression classes
• Implement the method toString in all concrete subclasses of Expression. The output of
toString should be a string representing the same expression. A leaf node would just return
the value in form of a string. An interior node would concatenate the result of toString
of the left side, the operator, and the result of toString of its right hand side operand. To
preserve operator precedence, add and sub would use parenthesis around their expression.
For example, the output for the two sample expressions in Fig. 1a and Fig. 1b would be
(3 + 4) ∗ 4 an ((3 + 4) + 4) respectively.
• Implement the method equals in all concrete subclasses of Expression. Two expression
nodes are equal if they have the same type and if their subtrees are equal. Two Value nodes
are equal if they contain the same value.
• Extend the expression classes with the Visitor pattern.
– Define an abstract class Visitor that contains methods for visiting all nodes in an
expression tree (all subclasses of Expression).
– Extend the class Expression with an abstract void accept(Visitor v) method.
– Implement the accept method in all concrete classes that extend Expression.
• Implement a class CalcVisitor that computes the numeric result of an expression tree.
If the problem statement is unclear, use the Canvas forum to ask for clarifications.
2
Turn in a zip file named blazerid hw5.zip. The file should contain an exported Eclipse project1
with the following items.
• All files needed to compile and run your solution.
• Your tests.
• A document (or text file) that states how the team collaborated on the assignment (responsibilities),
describes your design decisions, your tests, any difficulties you had. If you received
help from somebody else in class, please give credit to those students. If you would like to get
a graded version on paper, add a note at the top of the report saying “paper copy requested”.
Grading (50 pts max)
• (10pts) Lab attendance (Week of Feb 27.)
• (10pts) Assignment report (see paragraph above)
• (10pts) Turned in classes compile, code quality, Javadoc comments
• (10pts) The ExprCalculator produces a correct expression tree.
• (10pts) toString and equals work correctly.
• (10pts) Provision for the Visitor pattern is implemented.
• (10pts) CalcVisitor works correctly.
1
If you do not use Eclipse, the turned in file also needs to have a file readme.txt in its top directory that explains
how to compile and test your code.
3
Assignment 6
Calculator/Plotter due on March 19
Objectives: frameworks, inheritance, graphical user interface, graphics
This is a pair assignment. You can solve the assignment alone or in a team of two. Do not
copy code from other students or teams!
Background: This assignment builds on Assignment 5. You can use your own code, or the posted
model solution. The goal of this assignment is to create a plotter that reads an arithmetic expression
containing a variable, evaluates the expression over a given range, and plots the output as a graph.
Tasks:
• Enhance the ExprTreeCalculator with the ability to read variables.
– Introduce a new subclass of expression (e.g., Variable) that holds the name of a variable.
– Extend the visitor pattern with visit methods for the new sub-class.
– Extend the ExprTreeTokenizer so that it recognizes variables (a sequence of characters)
as a number.
• Create a graphical or text (your choice) user interface that allows the user to input the
expression, the range of the variable, and the size of the graphical window.
For example, a textual input could look like this.
plot in 300 x 300 for x from 0 to 20
x ∗ 2 + (1 / (x+1)) + 1
The first line describes what needs to be done. Plot in a 300×300 window, a graph for a
variable y ranging from 0 to 20. The second line is the function which we want to plot.
• Draw the graph on the screen
– Compute the step size for the evaluation. In the example, the step size would be 300
(size of output) divided by 20 (range of variable).
– Evaluate the expression at each step and store the coordinates.
– Creates a JFrame with a JComponent
– Draw the output into the JComponent
If the problem statement is unclear, use the Canvas forum to ask for clarifications.
1
Turn in a zip file named blazerid hw6.zip. The file should contain an exported Eclipse project1
with the following items.
• All files needed to compile and run your solution.
• Your tests.
• A document (or text file) that states how the team collaborated on the assignment (responsibilities),
describes your design decisions, your tests, any difficulties you had. If you received
help from somebody else in class, please give credit to those students. If you would like to get
a graded version on paper, add a note at the top of the report saying “paper copy requested”.
Grading (50 pts max)
• (10pts) Lab attendance (Week of Mar 6.)
• (10pts) Assignment report (see paragraph above)
• (10pts) Turned in classes compile, code quality, Javadoc comments
• (10pts) The ExprCalculator can read in expressions with variables, and the built-in methods
work correctly (i.e., toString, equals).
• (10pts) The user interface allows the user to input the desired data, and the data is processed
correctly.
• (10pts) The function is plotted correctly.
1
If you do not use Eclipse, the turned in file also needs to have a file readme.txt in its top directory that explains
how to compile and test your code.
2

Order from us and get better grades. We are the service you have been looking for.