Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TaskList {
- /**
- * Capacity of task's array.
- */
- private static final int CAPACITY = 10;
- /**
- * Index of last element in array
- */
- private int current;
- /**
- * Array of tasks
- */
- private Task[] element;
- /**
- * Empty constuctor
- */
- public TaskList() {
- element = new Task[CAPACITY];
- current = 0;
- }
- /**
- * Add task to array. If array is full makes new array and add task to
- * new array.
- * @param task added task
- */
- public void add(Task task) {
- if (current >= element.length) {
- Task[] temp = new Task[this.size() + CAPACITY];
- int index = 0;
- for (Task elem : element) {
- temp[index++] = elem;
- }
- element = temp;
- }
- element[current] = task;
- current++;
- }
Add Comment
Please, Sign In to add comment