EECS030 Lab 06

Due: Sunday Nov 08, 2020 before 11:59PM

Introduction

The main goals of this lab are to:

Specification

There are six kinds of (binary) expressions: addition, subtraction, multiplications, equality, greater-than, and less-than. The first three kinds are arithmetic expressions which evaluate to integers. The last three kinds are relational expressions which evaluate to Booleans (i.e., true or false). These six expression classes both inherit a more general class Expression, which maintains some basic attributes and methods that are common to all the six expressions (e.g., attributes to store operands and value, method to get value).

There are four kinds of expression collectors (each of which collecting a list of expressions):

These four classes both inherit a more general class ExpressionCollector, which maintains basic attributes and that are common to all the four collectors (e.g., the list to maintain the expression collectors, method to get result value).

The figure below shows the two inheritance hierarchies for expressions and expression collector which you are required to implement. They are also hinted in the JUnit tests given to you. Each arrow in the diagram corresponds to the extends keywords in Java.

You can assume that an expression collector only evaluates its collected expressions when it is type-correct: the collected expressions are either all arithmetic expressions (for add-all and times-all collectors) or all relational expressions (for conjoin-all and disjoin-all collections). We define that two expression collectors are equal if they are both type-correct and their evaluation results are the same.

Implementation

Download the shell project from the following zip file. DO NOT DOUBLE CLICK TO OPEN THIS ZIP FILE! You should import the project from the archive into your workspace as outlined in Lab 1.

Implement the given inheritance hierarchies, by

Given a JUnit test class (which relies on certain API of methods) and its expected outputs, complete the base classes, and implement the hinted subclasses such that all tests pass. Study the JUnit test class carefully to see what the expected outputs are for the various methods to be implemented. You may want to complete the Expression class and its subclasses (and pass the first 7 test cases), and then do the ExpressionCollectors and its subclasses. You may also find wrapper classes useful for manipulating results of evaluations. A wrapper class example is provided to you, which may help you understand how wrapper classes work.

A local copy of the Java API can be found here.

Submit

You should submit files Expression.java and its 6 subclasses, as well as ExpressionCollector.java and its 4 subclasses .

To submit your solution via the terminal (assuming you have used remotelab to build your code and complete the lab), first navigating to your the src directory for your project, and then issue the submit command into the terminal window to submit fiels one by one:

submit 2030 lab6 Expression.java
submit 2030 lab6 Addition.java
submit 2030 lab6 Subtraction.java
...

or, submit some or all file together, for example,

submit 2030 lab6 Expression.java  ExpressionList.java
submit 2030 lab6 Addition.java  Subtraction.java  Multiplication.java
submit 2030 lab6 GreaterThan.java LessThan.java Equal.java
...

At any time, you can issue submit -l 2030 lab6 into the terminal to check the files that you have submitted for lab6.

Alternatively, if you are using Eclipse on your own machine, you can upload your files through web submit .

Make sure you choose 2030 for the course, and lab6 for the assignment. Upload java files only, DO NOT SUBMIT the ZIP file of your project!