package com.javaops.run;
import com.javaops.model.Resume;
import com.javaops.storage.ArrayStorage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
/**
* Interactive test for com.javaops.storage.ArrayStorage implementation
* (just run, no need to understand)
*/
public class MainArray {
private final static ArrayStorage ARRAY_STORAGE = new ArrayStorage();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Resume r;
while (true) {
System.out.print("ÐведиÑе Ð¾Ð´Ð½Ñ Ð¸Ð· команд - (list | save uuid | update uuid | delete uuid | get uuid | clear | exit): ");
String[] params = reader.readLine().trim().toLowerCase().split(" ");
if (params.length < 1 || params.length > 2) {
System.out.println("ÐевеÑÐ½Ð°Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´Ð°.");
continue;
}
String uuid = null;
if (params.length == 2) {
uuid = params[1].intern();
}
switch (params[0]) {
case "list":
printAll();
break;
case "size":
System.out.println(ARRAY_STORAGE.size());
break;
case "save":
r = new Resume("uuid", "fullname");
ARRAY_STORAGE.save(r);
printAll();
break;
case "update":
r = new Resume("uuid", "fullname");
ARRAY_STORAGE.update(r);
printAll();
break;
case "delete":
ARRAY_STORAGE.delete(uuid);
printAll();
break;
case "get":
System.out.println(ARRAY_STORAGE.get(uuid));
break;
case "clear":
ARRAY_STORAGE.clear();
printAll();
break;
case "exit":
return;
default:
System.out.println("ÐевеÑÐ½Ð°Ñ ÐºÐ¾Ð¼Ð°Ð½Ð´Ð°.");
break;
}
}
}
private static void printAll() {
List