该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
The LFG must be further studied to find the most appropriate LFG values that
produce “more random” sequences. A useful and simple technique is to use a visual
aid. For example, below is a Java program that plots the values of the random
sequence as a bar graph. It can also be used to generate a statistical plot of the
frequency of occurrences of each number in the random sequence.
Task
Write your own version of the visualiser tool for the part 1, LFG sequences. Your
Java program must be capable of generating bar graphs for both the raw sequence of
numbers, and a statistical plot of the frequency of occurrence of each number in the
sequence. Your program must allow the user to select a colour scheme, and setup the
parameter values. Errors in the value of the parameters can be displayed as a message
box or sent to the standard error stream.
The bar graphs are self-adjusting. That is, depending on the size of the sequence of
numbers, the scale of the bar graph fits almost exactly to the size of the display area.
Requirements
Students are required to produce their own solutions to this task by constructing the
following source code files:
• File: Visualiser.java
o The main java program for this task, it constructs a derived JFrame
object which contains the various visual elements of the program.
• File: LaggedFib.java
o The LFG class, contains an interface for specifying the LFG values and
for generating the pseudo random numbers.
o A Vector object must be used to store the LFG seed values within a
LFG object.
• File: Stats.java
o A simple tally class that can be used to record the number of times a
particular number appears in the LFG sequence.
• File: VisualiserException.java
o An exception class for errors in the Visualiser class
• File: LaggedFibException.java
o An exception class for errors in the LaggedFib class
Note: a Java package must be constructed to contain your source code.
Submission
An electronic copy of your assignment must be emailed to your lecturer by the due
date.
Marking Scheme
The part is worth 20% of your overall CP2004 grade.
Execution: 15 marks
• Testing the program with various LFG values
Coding: 5 marks
• Appropriate code organisation
• Ordinary comments (see Chap 2 of the textbook)
• Code Formatting