Skip to content
Snippets Groups Projects
Commit ef456ccc authored by jonas.stirnema's avatar jonas.stirnema
Browse files

Broken append

parent 2761eb73
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,18 @@ public class DynArray {
}
}
public void make_sure_size(Contact a) {
if ((this.size + a.length) > this.capacity) // Overflow?
{
// Realloc new array
this.capacity *= 2;
Contact[] new_arr = new Contact[this.capacity];
copy_content(this.array, new_arr);
this.array = new_arr; // Copy pointer
}
}
public void show_it() {
System.out.println(this.toString());
}
......
......@@ -16,5 +16,8 @@ public class Main {
c2.show();
System.out.println(c1.toShortString());
c2.showShort();
DynArray contacts = new DynArray();
contacts.append();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment