MCS 270: Object-Oriented Software Development (Spring 2010)

Project Lab 1: Parser/Evaluator


Objective

Your assignment in this lab is to re-do in Java the shift-reduce parsing and evaluation lab which most of you did in Python in CS II. (By my count, three of you did it in Java, but the version I am giving you is a little different from the one you used, and I'm giving you some extra tasks.) I will give you a Java version of the initial form of that evaluator, much like the initial Python version most of you got in CS II. Your main task is to add the factorial operation to that evaluator. Additionally, I ask that you add appropriate documentation comments to those files and do a specific task which was given as an extra credit opportunity in CS II (see the Extra credit opportunities section below).

For your convenience, I include below links to the four previous semesters of the corresponding CS II lab, which I believe should cover all of you. You might also want to review section 13.2 of Concrete Abstractions.

Allowable collaboration

I will have you do a number of the in groups. This lab, however, I want you to do individually, since I want to be sure that all of you have mastered this level of Java and have become comfortable with MyEcipse. This means the coding must be entirely yours. However, feel free to help each other with using MyEclipse.

Getting started

I recommend that you start a new Java project in MyEclipse (call it Evaluator, or LabProject1, or whatever you want). Since I want you to start using packages and I put my files in a package called evaluator, you should next create a package called evaluator in your project. The java files I wrote can be found in evaluator.zip, which you should download somewhere. You can then install them into your project by moving or copying them into the src/evaluator subdirectory in your project (you will probably have to do this outside of MyEclipse). After doing this, you should right-click the Project Explorer window and select Refresh from the pop-up window. You should then see the four files I wrote in the evaluator package of your project.

Next, open these four files and run the file Evaluator.java in MyEclpse as a Java application. You should note that the main procedure in Evaluator.java has a single variable called expressionString which is set to a specific expression for evaluation. Feel free to modify this, for example by having it test multiple expressions or take input as an argument.

Documentation comments

Documentation comments are described on pages 162-166 of chapter 4 of our Core Java textbook, and I will talk about them in class on Friday. You should get into the habit of commenting your code well, from the very beginning. Sun supplies a program called javadoc which will take the documentation comments you have written in your code and create a suite of html files which describes the packages being documented, exactly as is done in the Java API documentation I have shown you.

Extra credit opportunities (though, not exactly)

All of the previous four semesters of CS II provided extra-credit opportunities for their projects, with the three most recent semesters providing one more opportunity than Spring 2008. I will expect you to at least do robust error checks by throwing Exceptions when they occur, and then handling those Exceptions appropriately. I encourage you to try some of the other extra credit options as well.

What to hand in

Please email me all of the java files used in your program. Easiest would be to package the whole package up into a zip file, but you may email them individually, if you prefer.

Possible addition

If I have time, I will show you to run JUnit tests on this program.