Programming and Problem Solving with Java

(やまだぃちぅ) #1

CASE STUDY


460


Scenarios:The processing takes place within the application class Rainfall: processing
a data set, writing the average, and repeating the process until no more data sites
remain. The class DataSetExceptionshould just pass the message sent to it on to its su-
perclass to be printed if the application ends with an error.Rainfallhas the responsibil-
ity to throw a DataSetExceptionif necessary.

CRC Cards:On the CRC card, we summarize RainFall’s responsibilities.

Class Name: DataSetException Superclass: Exception Subclasses:


Responsibilities Collaborations
Create itself

Pass message to super Super


Class Name: Rainfall Superclass: Object Subclasses:


Responsibilities Collaborations
Prepare the file for input FileReader, BufferedReader

Prepare the file for output FileWriter, PrintWriter
Process data BufferedReader
Throw exceptions if necessary DataSetException

Rainfall
input file
output file
DataSetException

T


E


A


M


F


L


Y


Team-Fly®

Free download pdf