Skip to content

Commit 99ca0fd

Browse files
committed
Lesson1_initial
0 parents  commit 99ca0fd

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.idea
2+
*.iml
3+
out
4+
log
5+
lib
6+
7+
8+

‎src/ArrayStorage.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Array based storage for Resumes
3+
*/
4+
public class ArrayStorage {
5+
Resume[] storage = new Resume[10000];
6+
7+
void clear() {
8+
}
9+
10+
void save(Resume r) {
11+
}
12+
13+
Resume get(String uuid) {
14+
return null;
15+
}
16+
17+
void delete(String uuid) {
18+
}
19+
20+
/**
21+
* @return array, contains only Resumes in storage (without null)
22+
*/
23+
Resume[] getAll() {
24+
return new Resume[0];
25+
}
26+
27+
int size() {
28+
return 0;
29+
}
30+
}

‎src/MainArray.java‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
*
3+
* Test for ArrayStorage
4+
*/
5+
public class MainArray {
6+
static ArrayStorage arrayStorage = new ArrayStorage();
7+
8+
public static void main(String[] args) {
9+
Resume r1 = new Resume();
10+
r1.uuid = "uuid1";
11+
Resume r2 = new Resume();
12+
r2.uuid = "uuid2";
13+
Resume r3 = new Resume();
14+
r3.uuid = "uuid3";
15+
16+
arrayStorage.save(r1);
17+
arrayStorage.save(r2);
18+
arrayStorage.save(r3);
19+
20+
System.out.println("Get r1: " + arrayStorage.get(r1.uuid));
21+
System.out.println("Size: " + arrayStorage.size());
22+
23+
printAll();
24+
arrayStorage.delete(r1.uuid);
25+
printAll();
26+
arrayStorage.clear();
27+
printAll();
28+
29+
System.out.println("Size: " + arrayStorage.size());
30+
}
31+
32+
static void printAll() {
33+
System.out.println("\nGet All");
34+
for (Resume r : arrayStorage.getAll()) {
35+
System.out.println(r);
36+
}
37+
}
38+
}

‎src/Resume.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* Resume class
3+
*/
4+
public class Resume {
5+
6+
// Unique identifier
7+
String uuid;
8+
9+
@Override
10+
public String toString() {
11+
return uuid;
12+
}
13+
}

0 commit comments

Comments
 (0)