Ok first off, yes I am a student and this is a project I am working on for class. Second, I am new to programming but so far I enjoy it and look forward to learning more. Third I am not looking for someone to do my work for me I just need help and feedback.*
Now what I am stuck on is making my menu options work (add new entry, delete, search, display, and exit), a loop for the menu options, at least one method, and two looping methods. Again I am not looking for you to do this for me I just want feedback and tips because again I do like this and I want to get more into programming.*
Take them one by one.
What should the code do to insert a new Address?
Here is how I do it with objects:
1) get the data from the user
2) create a new Address object
3) add that new object to the container
Since you are using an array, your approach will be different
One thing I'd do with your code is to define final int values for the indexes to the array.
For example:
final int ContactNbrIx = 0;
final int FirstNameIx = 1;
...
final int PhoneNbrIx = 7;
Then replace all the hardcoded magic numbers with these variables:
AddressBook[2][PhoneNbrIx]="412-555-1234";
Using variables you will be less likely to make a mistake later in the program when you want to see a particular value.
You wouldn't code: AddressBook[ix][PhoneNbrIx] when you want the zip code,
but you could code this: AddressBoox[ix][7] and not know what value you are referencing.
You may not have covered this yet, but arrays, being a fixed size, are not best suited to handling variable amounts of data, such as an address book. They're best reserved for fixed size data, such as days-of-the-week, months-of-the-year, countries, states, colors, planets, etc. For variable amounts of data, one of the Collection classes should be used - e.g. ArrayList. These allow you to add and/or remove as many items as you need without worrying about their size.
We flew down weekly to meet with IBM, but they thought the way to measure software was the amount of code we wrote, when really the better the software, the fewer lines of code...
Bill Gates
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Bookmarks