San Jose State University | CS 151 - OO Design Section 5 | Fall 2016

Homework 4

Put all work into a directory hw4 of your Git project and push it once a day. Don't put any code into packages. Don't put any code into a src subdirectory.

You are given an interface NumberSequence that represents a finite or infinite sequence of integers:

public interface NumberSequence
   long next();
   default boolean hasNext() { return true; }

  • In the NumberSequence interface, produce a static method random(long seed) that creates random numbers, using a linear congruential generator with m = 231, a = 1103515245 and c = 12345. Use iterate and a lambda expression.
  • Provide javadoc for the interface and all methods.
  • Here is a JUnit test class.