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.

Results 1 to 5 of 5

Thread: Address Book Help

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Address Book Help

    import java.io.*;
    import java.text.DecimalFormat;
     
    public class AddressBook{
    public AddressBook(){
    }
    DecimalFormat al = new DecimalFormat("#.##");
        private String name="";
        private String address="";
        private int telephone;
        private String email;
        private String att;
     
     
         public static void main( String[] args ){
         DecimalFormat al = new DecimalFormat("#.##");
     
            AddressBook aBook = new AddressBook();
            AddressBook bBook = new AddressBook();
            AddressBook cBook = new AddressBook();
     
            aBook.setName("Boy Katay");
            bBook.setName("Kris Manginum");
            cBook.setName("Ronald Spades");
     
            aBook.setAddress("123 SlaughterHouse");
               bBook.setAddress("26 Assumption Road");
            cBook.setAddress("89 Casino Avenue");
     
            aBook.setTelephone(4246512);
            bBook.setTelephone(4421231);
            cBook.setTelephone(6201130);
     
            aBook.setEmail("Katay@yahoo.com");
            bBook.setEmail("Arak@gmail.com");
            cBook.setEmail("Pusoy@hotmail.com");
     
            aBook.setAtt("Student");
            bBook.setAtt("Student");
            cBook.setAtt("Student");
     
     
     
     
            System.out.println(
            "Attributes/Properties    :"+aBook.getAtt()+
            "\nStudent Name        :"+aBook.getName()+
            "\nnAddress        :"+aBook.getAddress()+
            "\nTelephone        :"+aBook.getTelephone()+
            "\nEmail            :"+aBook.getEmail()+
     
            "\n\nAttributes/Properties    :"+bBook.getAtt()+
            "\nStudent Name        :"+bBook.getName()+
            "\nAddress            :"+bBook.getAddress()+
            "\nTelephone        :"+bBook.getTelephone()+
            "\nEmail            :"+bBook.getEmail()+
     
            "\n\nAttributes/Properties    :"+cBook.getAtt()+
            "\nStudent Name        :"+cBook.getName()+
            "\nAddress            :"+cBook.getAddress()+
            "\nTelephone        :"+cBook.getTelephone()+
            "\nEmail            :"+cBook.getEmail());
     
       }
     
     
        public String getName(){
           return name;      
        }
        public void setName( String name ){
           this.name = name;
        } 
        public String getAddress(){
            return address;
        }
        public void setAddress( String address ){
           this.address = address;
        }  
         public int getTelephone(){
           return telephone;      
        }
        public void setTelephone( int telephone ){
           this.telephone = telephone;
        }  
        public String getEmail(){
           return email;      
        }
        public void setEmail( String email){
           this.email= email;
        }
        public String getAtt(){
           return att;      
        }  
        public void setAtt( String att){
           this.att= att;
        }
     
    }

    How can I make this code so that I can create a class address book that can contain 50 entries of AddressBookEntry objects (using the code above). And it should provide the following methods for the address book.

    1. Add entry
    2. Delete entry
    3. View all entries
    4. Update an entry


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Address Book Help


  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Help

    import java.io.*;
    public class Test {
     
       public String name;
       public String address;
       public String number;
       public String email;
     
       //Accessor methods
       public String getName(){
           return name;
       }
           public String getAddress(){
                   return address;
       }
           public String getNumber(){
                   return number;
       }
           public String getEmail(){
                   return email;
       }
       //Mutator Methods
           public void setName(String name){
                   this.name = name;
       }
           public void setAddress(String address){
                   this.address = address;
       }
           public void setNumber(String number){
                   this.number = number;
       }
           public void setEmail(String email){
                   this.email = email;
       }
       public static void main(String[] akoceekwan)throws IOException{
           BufferedReader d = new BufferedReader(new InputStreamReader(System.in));
                          String[][] name = new String[50][4];
                    String[][] address = new String[50][4];
                    int[][] number = new int[50][4];
                    String[][] email = new String[50][4];
                      char a;
                   int asa;
                   Test ax = new Test();
                   do{
                   System.out.println("[1]Add Entry"+
                          "\n[2]Delete entry"+
                          "\n[3]View all entries"+
                          "\n[4]Update an entry"+
                          "\n[5]Exit"+
                          "\nChoose an Option:\t");
           asa = Integer.parseInt(d.readLine());
     
     
           if(asa == 1){
     
               System.out.println("Enter Name: ");
                   String s = d.readLine();
               System.out.println("Enter Address: ");
                   String u = d.readLine();
               System.out.println("Enter Telephone Number: ");
                   String g = d.readLine();
               System.out.println("Enter Email Address: ");
                   String o = d.readLine();
     
               ax.setName(s);
               ax.setAddress(u);
               ax.setNumber(g);
               ax.setEmail(o);
           }
           else if(asa == 3){
               System.out.println("Name: "+ax.getName()+
                                  "\nAddress: "+ax.getAddress()+
                                  "\nNumber: "+ax.getNumber()+
                                  "\nEmail: "+ax.getEmail());
           }
     
           }while(asa != 5);
                   System.out.println("Goodbye!");
     
           }
    }


    I have this so far... how can I make it contain the 50 entries? and the option "Delete entry"

    (java newbie self learning, i need more explanation on the subject.. thanks!)

  4. #4
    Member DavidFongs's Avatar
    Join Date
    Oct 2010
    Location
    Minneapolis, MN
    Posts
    107
    Thanks
    1
    Thanked 45 Times in 41 Posts

    Default Re: Address Book Help

    Why are you using 2 dimensional arrays in your main method? I fail to see the reasoning.

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Address Book Help

    Quote Originally Posted by DavidFongs View Post
    Why are you using 2 dimensional arrays in your main method? I fail to see the reasoning.
    so do i have to use 1 dimensional array? and did i put it in the right place?

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, 12:49 PM
  2. How to get your computer name and IP address?
    By JavaPF in forum Java Networking Tutorials
    Replies: 7
    Last Post: December 8th, 2011, 12:36 PM
  3. Java Book
    By stefanos in forum Java Theory & Questions
    Replies: 5
    Last Post: September 22nd, 2010, 01:38 PM
  4. Address of String instance
    By American in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 6th, 2010, 02:20 PM
  5. Array of contacts (address book)
    By smush in forum Collections and Generics
    Replies: 11
    Last Post: April 29th, 2010, 03:08 AM