COM 1205 Assignment #4. Assigned: Tuesday, 15 February 2000 Due: Tuesday, 22 February 2000 Working in small teams that are assigned by the instructor, you will design and code an implementation in Java of the Histogram ADT that is specified below. Your implementation of this module will be used by other students in a future assignment. Collaboration between members of different teams is forbidden. Each team is responsible for keeping its design and code hidden from other teams. Part of each team's grade will be determined by how well the team hides its code, and part of the grade will depend upon the quality of the implementation. A team that resolves the security issues and submits an implementation of the specified module that the instructor considers acceptable for use in a large software project will earn an A. The instructor will designate one member of each team as the lead programmer for that team. The lead programmer is responsible for submitting the team's work, and has the final say concerning all design, coding, and testing decisions. The lead programmer is also responsible for dividing the team's work among its members, and for scheduling team meetings at times that are convenient for the team. The other members of the team are responsible for advising the lead programmer, for reviewing the team's design, code, and tests, and for any other teamwork that may be assigned by the lead programmer. All members of a team will receive the same grade. Every student will serve as lead programmer for some assignment during the term. The teams will change at the whim of the instructor. The lead programmer is responsible for turning in the team's work before 4 pm on the due date by sending electronic mail to will@ccs.neu.edu with subject assignment #4 and a body that consists of the following, in the order shown: 1. The names of the team members. 2. Any remarks that the lead programmer wishes to make to the instructor concerning the team's work. 3. A line consisting of exactly 50 hyphens. 4. The code for Histogram.java. Late assignments may be discounted, and very late assignments may be discarded. -------------------------------------------------- Specification of the Histogram module. Histogram is an immutable abstract data type. Its operations shall have no visible side effects. The Histogram ADT shall be implemented in Java using JDK 1.2. The code for this implementation shall be in the statistics package, and shall consist of a single file named Histogram.java. This file shall define a public class named Histogram that defines the following public static methods, which are specified below. Signature: newHistogram: String -> Histogram newHistogram: StringBuffer -> Histogram length: Histogram -> int frequency: Histogram x char -> int frequency: Histogram x char x char -> int mic: Histogram x Histogram -> double Restrictions: The String and StringBuffer arguments to the newHistogram operations shall not be null, and shall contain only characters whose Unicode encoding is less than 128. Algebraic specification: Notation: s, s1, and s2 range over values of type String, and are not null. b ranges over values of type StringBuffer, and is not null. n, n1, n2, i, and j range over natural numbers of type int. c, c1, and c2 range over values of type char whose Unicode encoding is less than 128. h1 and h2 range over values of type Histogram. newHistogram (b) = newHistogram (b.toString()) length (newHistogram (s)) = s.length() If n is the number of times that char c occurs within s, then frequency (newHistogram (s), c) = n If n is the number of times that char c1 is followed by char c2 within s, then frequency (newHistogram (s), c1, c2) = n If n1 = length (h1), n2 = length (h2), then mic (h1, h2) Sigma (frequency (h1, c)) (frequency (h2, c)) c = ------------------------------------------------- n1 n2