/** * РеализÑйÑе и пÑоÑеÑÑиÑÑйÑе ArrayStorage.update(Resume resume) * СделайÑе пÑовеÑки: * в update/delete/get - ÑезÑме еÑÑÑ Ð² storage? * в save- ÑезÑме Ð½ÐµÑ Ð² storage? * ÑделайÑе в save пÑовеÑÐºÑ Ð½Ð° пеÑеполнение * вÑведиÑе ÑооÑвеÑÑÑвÑÑÑие пÑедÑпÑÐµÐ¶Ð´ÐµÐ½Ð¸Ñ Ð´Ð»Ñ Ð²ÑÐµÑ , ÑказаннÑÑ Ð²ÑÑе пÑовеÑок - System.out.println("Resume ...") * ÐзбавÑÑеÑÑ Ð¾Ñ Ð´ÑблиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð² коде ArrayStorage * ÐоÑмоÑÑиÑе на меÑÐ¾Ð´Ñ ÐºÐ»Ð°ÑÑа java.util.Arrays. * ÐекоÑоÑÑе из Ð½Ð¸Ñ Ð¿Ð¾Ð¼Ð¾Ð³ÑÑ ÑпÑоÑÑиÑÑ ÑеализаÑÐ¸Ñ Ð²Ð°ÑÐ¸Ñ Ð¼ÐµÑодов clear() и getAll() */ public class ArrayStorage { Resume[] storage = new Resume[10000]; int count = 0; Integer check(String uuid) { for (int i = 0; i <= count - 1; i++) { if (storage[i].uuid.equals(uuid)) { return i; } } return null; } private void update(Resume resume) { if (check(resume.uuid) != null) { System.out.println("Update possible"); } System.out.println("Error"); } void clear() { for (int i = 0; i <= storage.length - 1; i++) { storage[i] = null; } count = 0; } void save(Resume r) { if (check(r.uuid) != null) { System.out.println("Error. Resume is on base"); } else { if (count < storage.length) { storage[count] = r; count++; } else { System.out.println("Error. Base is full"); } } } Resume get(String uuid) { Integer check = check(uuid); if (check != null) { return storage[check]; } System.out.println("Error. Uuid didn't found"); return null; } void delete(String uuid) { Integer r = check(uuid); if (r != null) { storage[r] = storage[count - 1]; storage[count - 1] = null; count--; } else { System.out.println("Error. Unknown uuid"); } } /** * @return array, contains only Resumes in storage (without null) */ Resume[] getAll() { Resume allList[] = new Resume[count]; for (int i = 0; i <= count - 1; i++) { allList[i] = storage[i]; } return allList; } int size() { return count; } }