hw1 - 272 Homework Assignment 1 Fall 2008 Due: Wednesday,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
272 – Homework Assignment 1 Fall 2008 Due: Wednesday, October 15th, 5:00PM Do not discuss the problems with anyone other than the instructor or the TA. 1. Consider a simple class called BufferControl that keeps track of the number of items in a buFer, the number of items that have been inserted to the buFer, and the number of items that have been removed from the buFer. To simplify things we do not keep track of the items in the buFer in this class. BufferControl class has three integer ±elds: numItems , numInserted , and numRemoved . The constructor BufferControl() sets all three ±elds are equal to zero. BufferControl class has three methods: void insert() , void remove() , and int getNumItems() . getNumItems() returns the value of numItems and does not change the values of any ±elds. When insert() method is called numItems and numInserted are incremented by one and numRemoved remains the same. When delete() method can only be can only be called when numItems is greater than or equal to 1. When delete() method is called numItems is decremented by one and numRemoved is incremented by one and numInserted remains the same. (a) Write the contract for the BufferControl class in JML by writing the pre and post- conditions for each method. Also write the (strongest) class invariant. (b) Assume that there is another simple class called BoundedBufferControl . BoundedBufferControl class is very much like the BufferControl except that it has an- other integer ±eld called size . The constructor BoundedBufferControl(int s) requires the input value s to be greater than or equal to 1, sets size
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/04/2011 for the course CEN 5016 taught by Professor Workman,d during the Spring '08 term at University of Central Florida.

Page1 / 4

hw1 - 272 Homework Assignment 1 Fall 2008 Due: Wednesday,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online