-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSector.java
53 lines (44 loc) · 975 Bytes
/
Sector.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
public class Sector {
public byte[] array;
public Sector() {
this.array = new byte[Disk.SECTOR_SIZE];
}
public Sector(byte[] array){
this();
this.update(array);
}
public Sector(Sector other) {
this();
this.update(other);
}
public void update(byte[] array) {
if(array.length > this.size())
throw new IllegalArgumentException();
for(int i=0; i < array.length; i++)
this.array[i] = array[i];
}
public void update (Sector other) {
this.update(other.array);
}
public byte[] fill(byte[] buff) {
if(buff.length < this.size())
throw new IllegalArgumentException();
for(int i = 0; i < this.size(); i++)
buff[i] = this.array[i];
return buff;
}
public int size(){
return this.array.length;
}
public boolean equals(Sector other){
//Now redundant
if(this.size()!=other.size()){
return false;
}
for(int i=0;i<this.size();i++){
if(this.array[i]!=other.array[i])
return false;
}
return true;
}
}