-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalList.java
More file actions
69 lines (62 loc) · 1.78 KB
/
AnimalList.java
File metadata and controls
69 lines (62 loc) · 1.78 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Provides the structure for which to create a
* list of multiple {@link Animal} objects, which can grow and change
* in size.
*
* @author Jackson Eshbaugh
* @version 02/10/2024
*/
public interface AnimalList {
/**
* Appends an animal to the end of the list.
*
* @param animal the {@link Animal} object to add to the list
*/
void add(Animal animal);
/**
* Searches the list for {@code animal}
* and removes it from the list, if found.
*
* @param animal the {@link Animal} to remove from the list
*/
void remove(Animal animal);
/**
* Removes an animal from the list
* by its index.
*
* @param index the index to remove from the list
* @return the {@code Animal} that was removed from the list
* @throws IndexOutOfBoundsException when the {@code index} is too small
* or too large
*/
Animal remove(int index);
/**
* Gets the list element at the specifed index.
*
* @throws IndexOutOfBoundsException when the index is not in the boundary of [0, size() -1].
* @param index the index from which to retrieve an element
* @return the element at the specified index
*
*/
Animal get(int index);
/**
* Finds the specified {@code animal} in the list,
* and returns its index.
*
* @param animal the {@link Animal} to find in the list
* @return the index of {@code animal} or {@code -1} if {@code animal}
* was not found
*/
int find(Animal animal);
/**
* Clears the list, returning it to its
* default, empty state.
*/
void clear();
/**
* Gets the current size of the list.
*
* @return the current size of the list
*/
int size();
}