[Solved] CSE 522 Assignment 5 Part 2 -Design by Contract

$25

File Name: CSE_522_Assignment_5_Part_2_-Design_by_Contract.zip
File Size: 442.74 KB

SKU: [Solved] CSE 522 Assignment 5 Part 2 -Design by Contract Category: Tag:
5/5 - (1 vote)

Posted on Piazza:Resources Assignments is a zip file CFJ_BST_Iter.zip. Unzip this file to obtain a directory CFJ_BST_Iter containing a fully configured project which you may import into Eclipse by doing: File Import Existing Projects into Workspace. The added configurations permit the inclusion of CoFoJa contract annotations in the Java source.

The imported project contains a file BST_Contract.java with the familiar Tree and DupTree classes along with a class BST_Iterator which works on both trees and duptrees. The class DupTree extends Tree and the values in both types of trees are integers. Also included is an @Invariant(ordered()) clause for class Tree.

Your task in this part of the assignment is to write CoFoJa contracts (@Requires and @Ensures annotations) for the constructor of BST_Iterator and the two methods that modify its state, namely, next() and stack_left_spine().

Writing Contracts. The contracts should capture the basic requirements and properties of the iterator, namely, that:

  1. the iterator only works on binary search trees;
  2. the values are returned in ascending order; and
  3. the stack invariant (described in Lecture 9) is maintained.

Your contracts may refer to the fields count, value and stack of BST_Iterator as well as functions that do not modify the state of any object, such as Tree.min(), Tree.max(),

Tree.ordered(), Stack.isEmpty(), Stack.peek(), BST_Iterator.hasNext(), etc.

Running the Program. In order to run your program, you need to give the name of the .jar file in the VM Arguments of the Run Configuration, as follows:

-javaagent:lib/cofoja+asm-1.3.1-20170424.jar

Run BST_Contract.java augmented with contracts and ensure that the program works correctly.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSE 522 Assignment 5 Part 2 -Design by Contract
$25