-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSequence.java
More file actions
42 lines (35 loc) · 857 Bytes
/
Copy pathSequence.java
File metadata and controls
42 lines (35 loc) · 857 Bytes
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
package compresseur;
public class Sequence {
int numberOfElements;
int numberOfBitsPerByte;
int size;
public Sequence() {
this.numberOfBitsPerByte = 0;
this.numberOfElements = 0;
this.size = 0;
}
public Sequence(int numberOfBits) {
this.numberOfBitsPerByte = numberOfBits;
this.numberOfElements = 1;
this.size = numberOfBits;
}
public int getSize() {
return size;
}
public int getNumberOfElements() {
return numberOfElements;
}
public void addAByte(int minimumSize) throws TooLongSequenceException {
if(numberOfElements == 256) {
throw new TooLongSequenceException();
}
if(minimumSize > numberOfBitsPerByte) {
numberOfBitsPerByte = minimumSize;
}
numberOfElements++;
size = this.numberOfBitsPerByte * this.numberOfElements;
}
public int getNumberOfBitsPerByte() {
return numberOfBitsPerByte;
}
}