thanks for the help anyways, looks like i'm repeating the first year again probably for the best
Type: Posts; User: Gamb1t
thanks for the help anyways, looks like i'm repeating the first year again probably for the best
I think thats how its meant to i really havent a clue anymore
i may as well just leave it not gonna get this sorted i just keep going round in circles and wasting your time
its the index of the last element in the list
It's a count of the last element in the list i think so it's to do with the number of entries/contacts not the number of data variables in each
I have these
//index of the last entry
private int top = 0;
//constant number that indicates the maximum
//number of entries in the address book
private static final int...
Is this something different to the null thing?
so my variable is list[top]
so i need to use the top and that sets the amount of loops,
i really can't think anymore
Okay that makes sense but where and how do i do this? Sorry my brain has melted :(
Contact@3bc0f2e5
Street Address: west, City: south, County: east, Country north, Postcode: null
Forename: phil, Surname: stone
Contact@788ab708
Street Address: south , City: east, County:...
It compiles but i get an error message when i use the method - "java.lang.NullPointerException: null"
error message points System.out.println(top.toString());
It's seems to show everything but it...
So i need
for (Contact top : list)
{
System.out.println(top.toString());
}
??
The data i want to print is all the variables from name and all the variables from address.
All of which is found under
Name name = new Name(forename, surname);
Postcode postcode =...
So i only need to call it once as it takes care of all the variables?
And do i then need to override it and have it with the AddressBook class too
God i'm getting frustrated and i'm not gonna get...
The list variable is in the class AddressBook set as an array
private Contact[] list;
The toString method comes from Contact class
@Override
public String toString() {
...
So
for (Contact index : list)
{
System.out.println(index.toString());
}
This says for each Contact index in list then system prints out the index...
I should use a for each loop shouldn't i, so for each of the data values in an index use toString and enter the value. And will need an arraylist then i imagine - it's something like this isn't it - ...
It seemed the only way to get it to compile.
I require this - addressbook.viewContact(contact); so it links to addressbook and performs the function.
And it says it can't find the variable contact....
Though i seem to have an issue.
After entering 2 contacts and then requesting to view the list i got this printed for some strange reason
Street Address: townsend croft, City: coventry, County:...
Sorry it's tiredness and my punctuation is going to pot.
Correction - making silly mistakes it's fine now it will display the list
public void viewEntries(){
String forename = "";...
This just declares a Contact arraylist doesn't it , if its pointing at Contact class it shouldnt matter should it as if its declared in AddressBook it would be the same i think as it would be the...
I think it's looking at the Contact class:
public class Contact
{
private Address address;
private Name name;
public Contact(Name name, Address address)
Damn of course i missed it.
So now
public void viewEntries(){
if(addressbook.isEmpty()){
System.out.println("Address Book is full");
return;
...
oops good point.
Added to Address class:
boolean isEmpty() {
return top = 0;
}
However it expects int so if i use
thanks,
now onto show all entries:
In my Contact class
public void showContact(Contact contact)
{
for( int index = 0; index < top; index++)
So i've finally sorted out my AddressBook class i think and still sorting out the addEntry method in the Textui
Having two issues, 1st the try{ is an unreachable statement and i can't figure out...