Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 4 of 9 FirstFirst ... 23456 ... LastLast
Results 76 to 100 of 209

Thread: Address Book Program Issues

  1. #76
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    You should be able to correct those errors with making a post.

  2. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  3. #77
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    making a post? a new thread?

  4. #78
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    No, I was commenting on post #75

  5. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  6. #79
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    I'm confused i can fixed the error how?

  7. #80
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    i can fixed the error how?
    What error?

  8. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  9. #81
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    For the
    Name name = new Name(forename, surname);

    It says that it cannot find the variable forename and i assume it will be the same for the rest.
    At the top the instance variable is just
    private AddressBook addressbook;

    Which holds
    public AddressBook(Contact contact)
        {
            this.contact = contact;
        }

    If i add
    private Contact contact;
    to the addressbookui i still get the same error

  10. #82
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Where is the variable forename defined?
    In the addEntry method you define all the variables to hold the data from the user.
    Then you read in the values.
    Now you are trying to use those values to create objects.

    Look at that code and see what is the name of the variable that your are trying to use.
    Where is it defined. It should be defined at the method level and not inside of a some block of code surrounded by {}s.

    What method are working on now? I thought you were in the addEntry method. That is where all the data is.

  11. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  12. #83
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    Yeah sorry i was using that as a constructor for some reason.
    It's know within the addEntry method and the name statement works, the address for somereason doesn't

    public void addEntry()
        {
        BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in));
        String forename = "";
        String surname = "";
        String street = "";
        String city = "";
        String county = "";
        String country = "";
        String post = "";
        if(top == MAXENTRIES){
            System.out.println("Address Book is full");
            return;
        }
        //asks the user for the data of the address book
        try{
            System.out.print("Forename: ");
            forename = keyIn.readLine();
            System.out.print("Surname: ");
            surname = keyIn.readLine();
            System.out.print("Street: ");
            street = keyIn.readLine();
            System.out.print("City: ");
            city = keyIn.readLine();
            System.out.print("County: ");
            county = keyIn.readLine();
            System.out.print("Country: ");
            country = keyIn.readLine();
            System.out.print("Postcode: ");
            post = keyIn.readLine();
     
        }catch(Exception e){
            System.out.println(e);
            System.exit(0);
        }
        Name name = new Name(forename, surname);
        Address address = new Address(street, city, county, country, post);    
     
      }

    It says cannot find symbol - constructor Address(java.lang.String, java.lang.String, ditto etc.)

  13. #84
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Look at the definition for the Address class and see if any of its constructor takes the arguments you are trying to pass it. If not, add a constructor to the Address class that takes those 5 String values and stores them into local variables.

  14. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  15. #85
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    In my address class i have this constructore

    public Address(String street, String city, String county, String country, Postcode post)
        {
            this.street = street;
            this.city = city;
            this.county = county;
            this.country = country;
            this.post = post;
        }

    So guess the issue is that post doesnt take String

  16. #86
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    A Postcode object is NOT a String.
    You need to create a Postcode object and use that in the constructor call to make a new Address.

  17. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  18. #87
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    How do i do that then within the constructor i already have or a new one

  19. #88
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    You don't do it in the Address class. You do it in the addEntry method. Create a Postcode object and use it when you call the Address class constructor.

  20. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  21. #89
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    So i created
    Name name = new Name(forename, surname);
            Postcode postcode = new Postcode(post);
            Address address = new Address(street, city, county, country, post);
    in addentry() method

  22. #90
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Does it compile?
    Have you tried executing it?
    What happens?

  23. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  24. #91
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    i tried and i have the same error message as before

  25. #92
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    When you have an error, please post the full text.

  26. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  27. #93
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    Name name = new Name(forename, surname);
            Postcode postcode = new Postcode(post);
            Address address = new Address(street, city, county, country, post);

    the last line - error message: cannot find symbol - constructor Address(java.lang.String, java.lang.String, ditto etc.)

  28. #94
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Did you change the last argument in the list to be a Postcode object and not a String?

  29. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  30. #95
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    In the list i presume you mean this:

    String forename = "";
        String surname = "";
        String street = "";
        String city = "";
        String county = "";
        String country = "";
        Postcode post = "";
    if(top == MAXENTRIES){
            System.out.println("Address Book is full");
            return;
        }
        //asks the user for the data of the address book
        try{
            System.out.print("Forename: ");
            forename = keyIn.readLine();
            System.out.print("Surname: ");
            surname = keyIn.readLine();
            System.out.print("Street: ");
            street = keyIn.readLine();
            System.out.print("City: ");
            city = keyIn.readLine();
            System.out.print("County: ");
            county = keyIn.readLine();
            System.out.print("Country: ");
            country = keyIn.readLine();
            System.out.print("Postcode: ");
            post = keyIn.readLine();
     
        }catch(Exception e){
            System.out.println(e);
            System.exit(0);
        }
     
    Name name = new Name(forename, surname);
            Postcode postcode = new Postcode(post);
            Address address = new Address(street, city, county, country);

    Another error message on
    Postcode post = "";
    found java.lang.String but expected Postcode
    Last edited by Gamb1t; August 25th, 2011 at 03:00 AM.

  31. #96
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Postcode post = "";
    "" is a String, not a Postcode object. You can Use null to initialize the variable when you define it.
    However you use the variable post to read in a String from the user, so post should be defined as a String not as a Postcode as you did in post#83.

  32. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  33. #97
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    Quote Originally Posted by Norm View Post
    Did you change the last argument in the list to be a Postcode object and not a String?
    I thought you were referring to that part to change it from a String to a Postcode object

  34. #98
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    I thought you were referring to that part to change it from a String to a Postcode object
    What and where are you talking about? You need to be specific and show the code.

    The constructor takes a Postcode object.
    You read data from a user into a String object.
    Last edited by Norm; August 25th, 2011 at 08:47 AM.

  35. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

  36. #99
    Member
    Join Date
    Aug 2011
    Posts
    106
    Thanks
    81
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Program Issues

    This is all of my textUI at the moment i don't have a constructor
    public class AddressTextUi
    {
        //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 MAXENTRIES = 10;   
        //
        private Contact[] list;
        private AddressBook addressbook;
        private Contact contact;
     
     
        public void mainMenu()
        {
            displayMainMenu();     
        }
     
     
     
       /**
      *The main method - DISPLAYS OPTIONS, TAKES THE OPTION AND CHECKS APPROPRIATE ACTION
      */
        private void displayMainMenu(){
        BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in));
        AddressTextUi addressBook = new AddressTextUi();
        String act = "";
        while(true)
        {
            //displays the options
            System.out.println("\n[A] ADD ENTRY");
            System.out.println("[D] DELETE ENTRY");
            System.out.println("[U] UPDATE ENTRY");
            System.out.println("[V] VIEW ALL ENTRIES");
            System.out.println("[S] SEARCH ENTRIES BY SURNAME");
            System.out.println("[Q] Quit");
            System.out.println("Enter desired action: ");
            try{
            //gets the choice
            act = keyIn.readLine();
           }catch(Exception e){
            System.out.println("Error");
           }
           //checks for the appropriate action
           if(act.equals("A")||act.equals("a"))
           addressBook.addEntry();
           else if(act.equals("Q")||act.equals("q"))
           {System.out.println("Program Closing Down");
            System.exit(0);}
           else
            System.out.println("Unknown command");
        }
     }
     
        public void addEntry()
        {
        BufferedReader keyIn = new BufferedReader(new InputStreamReader(System.in));
        String forename = "";
        String surname = "";
        String street = "";
        String city = "";
        String county = "";
        String country = "";
        String post = "";
        if(top == MAXENTRIES){
            System.out.println("Address Book is full");
            return;
        }
        //asks the user for the data of the address book
        try{
            System.out.print("Forename: ");
            forename = keyIn.readLine();
            System.out.print("Surname: ");
            surname = keyIn.readLine();
            System.out.print("Street: ");
            street = keyIn.readLine();
            System.out.print("City: ");
            city = keyIn.readLine();
            System.out.print("County: ");
            county = keyIn.readLine();
            System.out.print("Country: ");
            country = keyIn.readLine();
            System.out.print("Postcode: ");
            post = keyIn.readLine();
     
        }catch(Exception e){
            System.out.println(e);
            System.exit(0);
        }
        Name name = new Name(forename, surname);
        Postcode postcode = new Postcode(post);
        Address address = new Address(street, city, county, country);    
     
     
      }
    }

  37. #100
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,719
    Thanks
    45
    Thanked 1,974 Times in 1,948 Posts

    Default Re: Address Book Program Issues

    Does your code compile without errors?

  38. The Following User Says Thank You to Norm For This Useful Post:

    Gamb1t (August 25th, 2011)

Page 4 of 9 FirstFirst ... 23456 ... LastLast

Similar Threads

  1. Source code for Email address book/contacts importer
    By jega004 in forum Java Theory & Questions
    Replies: 4
    Last Post: November 23rd, 2012, 11:49 AM
  2. Issues with ascending number program
    By newtojava2011 in forum What's Wrong With My Code?
    Replies: 21
    Last Post: June 30th, 2011, 06:23 PM
  3. Address Book Help
    By clevel211 in forum Object Oriented Programming
    Replies: 4
    Last Post: November 21st, 2010, 08:42 PM
  4. How to get your computer name and IP address?
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 6
    Last Post: November 11th, 2010, 04:06 AM
  5. Array of contacts (address book)
    By smush in forum Collections and Generics
    Replies: 11
    Last Post: April 29th, 2010, 03:08 AM