In this assignment, you will write a command-line version of an HP calculator that uses decorators as the main instrument for implementing calculator computations. In effect, you will enter a sequence of commands via the command line, and the output will be the result:
> java hp35.Main 4 3 2 x +
4 3 2 x + = 10
The goals of this assignment are for you to learn:
> java hp35.Main 4 3 2 x +will produce the following decorator chain -- one decorator for each command line argument, with the base (terminal) of the chain is an instance of End:
stack = new Stack<float>();Your task is to:
System.out.println(" = " + stack.pop());
System.out.println("stack not empty -- missing arguments");
You are to submit a working Calculator that parses and correctly evaluates the following script. You can invoke this script by typing:
> java hp35.Main -f testscript.txt
Your program may be subjected to other scripts when being graded. Specifically:
zip file with all source code. The zip file must unzip into
bash script to invoke your refactored program
A critical part of any design is clarity and understandability. Hence, you will be graded on the clarity of your project and its ability to work correctly. Sloppy code, documentation, or anything that makes grading or understanding your program difficult will cost you points! Beware, some of these "beauty" points are subjective.
No late assignments/submissions will be accepted.