Computers and Technology

Assume that the classes listed in the Java Quick Reference have been imported where 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 AdditionPattern object is constructed with two positive integer parameters, as described below.
The 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.
The AdditionPattern class also supports the following methods.
currentNumber, 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
The following table illustrates the behavior of an AdditionPattern object that is instantiated by the following statement.
AdditionPattern plus3 = new AdditionPattern(2, 3);
Method Call Value Returned Explanation
(blank if no value)
plus3.currentNumber(); 2 The current number is initially the
starting number in the pattern.
plus3.next(); The pattern adds 3 each time, so
move to the next number in the
pattern (5).
plus3.currentNumber(); 5 The current number is 5.
plus3.next(); The pattern adds 3 each time, so
move to the next number in the
pattern (8).
plus3.next(); The pattern adds 3 each time, so
move to the next number in the
pattern (11)
plus3.currentNumber(); 11 The current number is 11.
plus3.prev(); Move to the previous number in
the pattern (8).
plus3.prev(); Move to the previous number in
the pattern (5).
plus3.prev(); Move to the previous number in the
pattern (2).
plus3.currentNumber(); 2 The current number is 2.
plus3.prev(); There is no previous number in the
pattern prior to 2, so no action is
taken.
plus3.currentNumber(); 2 The current number is 2.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 04:31, genyjoannerubiera
This graph compares the cost of room and board at educational institutions in texas.
Answers: 1
image
Computers and Technology, 23.06.2019 07:30, emilyplays474
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
image
Computers and Technology, 23.06.2019 16:00, keyonaemanieevans
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
image
Computers and Technology, 23.06.2019 19:30, carcon2019
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
Do you know the correct answer?
Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Un...

Questions in other subjects:

Konu
Physics, 18.07.2019 11:00