-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sequence.java
98 lines (85 loc) · 3.03 KB
/
Sequence.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
public class Sequence{
private int numOfElementsToCalculate;
private int[] sequence;
private int[] noteSequence;
private int modulusOfElementsConvertingToNote;
private int noteOffset;
/**
* Constructor
* @param numOfElementsToCalculate This is the number of elements to calculate in the sequence.
*/
public Sequence(int numOfElementsToCalculate){
this.numOfElementsToCalculate = numOfElementsToCalculate;
this.sequence = new int[numOfElementsToCalculate];
this.noteSequence = new int[numOfElementsToCalculate];
this.modulusOfElementsConvertingToNote = numOfElementsToCalculate;
this.noteOffset = 0;
}
/**
* Constructor
* @param numOfElementsToCalculate This is the number of elements to calculate in the sequence.
* @param modulusOfElementsConvertingToNote This is the modulus value for each element in the noteSequence will
* be modulo of the corresponding value in sequnce.
*/
public Sequence(int numOfElementsToCalculate, int modulusOfElementsConvertingToNote){
this.numOfElementsToCalculate = numOfElementsToCalculate;
this.sequence = new int[numOfElementsToCalculate];
this.noteSequence = new int[numOfElementsToCalculate];
this.modulusOfElementsConvertingToNote = modulusOfElementsConvertingToNote;
this.noteOffset = 0;
}
/**
* Constructor
* @param numOfElementsToCalculate This is the number of elements to calculate in the sequence.
* @param modulusOfElementsConvertingToNote This is the modulus value for each element in the noteSequence will
* be modulo of the corresponding value in sequnce.
* @param noteOffset This value will be added to each value in the sequence while converting
* them the notes.
*/
public Sequence(int numOfElementsToCalculate, int modulusOfElementsConvertingToNote, int noteOffset){
this.numOfElementsToCalculate = numOfElementsToCalculate;
this.sequence = new int[numOfElementsToCalculate];
this.noteSequence = new int[numOfElementsToCalculate];
this.modulusOfElementsConvertingToNote = modulusOfElementsConvertingToNote;
this.noteOffset = noteOffset;
}
public int getNumOfElementsToCalculate() {
return numOfElementsToCalculate;
}
public int[] getSequence(){
return sequence;
}
public int[] getNoteSequence(){
return noteSequence;
}
public int getNoteOffset(){
return noteOffset;
}
public int getModulusOfElementsConvertingToNote(){
return modulusOfElementsConvertingToNote;
}
public void setNoteOffset(int noteOffset){
this.noteOffset = noteOffset;
}
public void setModulusOfElementsConvertingToNote(int modulusOfElementsConvertingToNote){
this.modulusOfElementsConvertingToNote = modulusOfElementsConvertingToNote;
}
/**
* Prints the sequence.
*/
public void printSequence(){
for(int num : sequence){
System.out.print(num + " ");
}
System.out.println();
}
/**
* Prints the noteSequence.
*/
public void printNoteSequence(){
for(int num : noteSequence){
System.out.print(num + " ");
}
System.out.println();
}
}