-
Notifications
You must be signed in to change notification settings - Fork 0
/
linkedl_list_DB.java
53 lines (40 loc) · 1.48 KB
/
linkedl_list_DB.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
import java.io.*;
import java.util.*;
import java.util.LinkedList;
import java.util.Scanner;
// using linked list
public class linkedl_list_DB {
LinkedList<Army_schema> linkedList = new LinkedList<Army_schema>(); // ll of the Army
static int index = 0;
// Database() {index = 1; }
// Methods For Data Manupulation using LL
public Army_schema createArmyStorage(String name, Army_schema army) {
if (name.isBlank())
return null;
else {
System.out.println("INDEX -> " + index++);
linkedList.addLast(/* index++, */ army); // Syntax : add(int index, Object)
// System.out.println("running method");
return army; // return type - Army_schema
}
}
public Army_schema getArmyByIdStorage(int id) {
return linkedList.get(id); // LinkedList.get(int index)
}
public Army_schema updateArmyStorage(int ID_index, String name, String age, String rank, String gender,
String location_zone, String phone_num, String address) {
// System.out.println("why ur NOT running");
return linkedList.get(ID_index).updateArmyDetails(name, age, gender, rank, location_zone, phone_num, address);
}
public Army_schema deleteArmyStorage(int index) {
return linkedList.remove(index);
}
public void getAllArmyStorage() {
int len = linkedList.size(), i;
System.out.println("Length of LinkedList = " + len);
for (i = 0; i < len; i++) {
Army_schema troop = linkedList.get(i);
System.out.println(troop.obj_show());
}
}
}