0% found this document useful (0 votes)
5 views2 pages

Classes AdditionPattern FRQ

The document outlines the requirements for implementing the AdditionPattern class in Java, which generates a number pattern based on a starting number and an increment value. It describes the methods available in the class, including currentNumber, next, and prev, and provides an example of how the class operates. The implementation must adhere to specified behaviors and examples to receive full credit.

Uploaded by

cursedorange74
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Classes AdditionPattern FRQ

The document outlines the requirements for implementing the AdditionPattern class in Java, which generates a number pattern based on a starting number and an increment value. It describes the methods available in the class, including currentNumber, next, and prev, and provides an example of how the class operates. The implementation must adhere to specified behaviors and examples to receive full credit.

Uploaded by

cursedorange74
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

‭ lasses: AdditionPattern FRQ‬

C
‭Testing code:‬‭[Link]

‭ ssume that the classes listed in the Java Quick Reference have been imported where‬
A
‭appropriate.‬
‭Unless otherwise noted in the question, assume that parameters in method calls are not null‬
‭and that methods are called only when their preconditions are satisfied.‬
‭In writing solutions for each question, you may use any of the accessible methods that are listed‬
‭in classes defined in that question. Writing significant amounts of code that can be replaced by‬
‭a call to one of these methods will not receive full credit.‬
‭This question involves the implementation of the‬‭ AddtionPattern‬‭class, which generates a‬
‭number pattern. The‬‭ AddtionPattern‬‭object is constructed‬‭with two positive integer‬
‭parameters, as described below.‬

T‭ he first positive integer parameter indicates the starting number in the pattern.‬
‭The second positive integer parameter indicates the value that is to be added to obtain each‬
‭subsequent number in the pattern.‬
AddtionPattern‬‭class also supports the following‬‭methods.‬
‭The‬‭

‭urrentNumber‬
c ‭, which returns the current number in‬‭the pattern‬
next‬
‭ ‭, which moves to the next number in the pattern‬
prev‬
‭ ‭, which moves to the previous number in the pattern‬‭or takes no action if there is no‬
‭previous number‬
AddtionPattern‬‭object that is instantiated‬
T‭ he following table illustrates the behavior of an‬‭
‭by the following statement.‬

AdditionPattern plus3 = new AdditionPattern(2, 3);‬


‭Method Call‬ ‭Value Returned‬ ‭Explanation‬


‭(blank if no value)‬
[Link]();‬ ‭
‭ 2‬ T‭ he current number is initially the‬
‭starting number in the pattern.‬
[Link]();‬
‭ ‭The pattern adds 3 each time, so‬
‭move to the next number in the‬
‭pattern (5).‬
[Link]();‬ ‭
‭ 5‬ ‭The current number is 5.‬
[Link]();‬
‭ ‭The pattern adds 3 each time, so‬
‭move to the next number in the‬
‭pattern (8).‬
[Link]();‬
‭ ‭The pattern adds 3 each time, so‬
‭move to the next number in the‬
‭pattern (11).‬
‭[Link]();‬
p 11‬
‭ ‭The current number is 11.‬
[Link]();‬
‭ ‭Move to the previous number in the‬
‭pattern (8).‬
[Link]();‬
‭ ‭Move to the previous number in the‬
‭pattern (5).‬
[Link]();‬
‭ ‭Move to the previous number in the‬
‭pattern (2).‬
‭[Link]();‬
p 2‬
‭ ‭The current number is ‬‭
2‭.‬‬
[Link]();‬
‭ T‭ here is no previous number in the‬
‭pattern prior to 2, so no action is‬
‭taken.‬
[Link]();‬
‭ 2‬
‭ ‭The current number is ‬‭
2‭.‬‬

‭ rite the complete‬‭


W AdditionPattern‬‭class. Your implementation‬‭must meet all‬
‭specifications and conform to all examples.‬

You might also like