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 16 of 16

Thread: NEED HELP TO FIX Object oriented Program Facebook

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation NEED HELP TO FIX Object oriented Program Facebook

    Here is the Story, I want to make a object oriented program, and choose Facebook as an objeck...
    The case :
    The Facebook account has four different Type: Artist, people, shop, politic
    and there are some method that I must use :
    -become_fans_artist
    -become_friends
    -add_friends
    -become_member
    -support_politic
    -look_list_friend (people)
    -look_list_support_politic (politic)
    -look_list_fans (artist)
    -look_list_member (shop)

    I'v updated the code.. I don't know it is right or not.. but i've tried it and no error.
    I used 1 package and 5 class : facebook,people,artist,politic, and shop.

    public class Facebook {   
        public static void main(String args[]){
     
    		people orang1 = new people("James","Sukabirus 26","29 Februari 1992");
     
    		Artist artis1 = new Artist("Jeffry Adityatama","Sukabirus","22 Februari 1990");
     
    		people orang2 = new people("Tane Yoroshi","Sukapura","22 Agustus 1990");
     
    		Artist artis2 = new Artist("Amru Rizaldy","Sempur Bogor","25 September 1991");
     
    		shop toko1 = new shop("Shelly Shop","sukabirus");
     
    		Politic politikus1 = new Politic("Risman Rangga","Bandung","22 Oktober 1966");
     
    		orang2.Become_fans(artis2);
    		politikus1.Become_fans(artis2);
    		orang1.Become_member(toko1);
    		orang2.Become_member(toko1);
    		orang1.add_friend(orang2);
    		orang1.support_politics(politikus1);
    		artis2.Look_list_fans();
    		politikus1.Look_list_supporter();
    		toko1.Look_list_member();
     
    	}    
    }
     
    public class people {
          private String name,address,born;
     
        public people(){}
        public people(String nama, String alamat, String ttl){
        this.name=nama;
        this.address=alamat;
        this.born=ttl;
        }
     
     
        public String getNamePeople(){
        return name;
        }
        public String getAddressPeople(){
        return address;
        }
        public String getBornPeople(){
        return born;
        }
     
     
        public void add_friend(people t){}
     
     
        void Become_member(shop T) {
     
        }
     
        void support_politics(Politic P) {       
     
        }
     
        void Become_fans(Artist A) {
     
        } 
    }
     
    public class Artist {
             private String name,address,born;
     
        public Artist(){}
        public Artist(String nama, String alamat, String ttl){
        this.name=nama;
        this.address=alamat;
        this.born=ttl;
        }
     
     
        public String getNameArtist(){
        return name;
        }
        public String getAddressArtist(){
        return address;
        }
        public String getBornArtist(){
        return born;
        }
     
     
        public void Look_list_fans(){
         System.out.println("List fans ");
         System.out.println("1.Tane Yoroshi");
         System.out.println("2.Risman Rangga");
     
        }      
    }
     
    public class shop {
              private String name,address;
     
        public shop(){}
        public shop(String nama, String alamat){
        this.name=nama;
        this.address=alamat;
     
        }
     
     
        public String getNamePeople(){
        return name;
        }
        public String getAddressPeople(){
        return address;
        }
     
     
     
         public void Look_list_member(){
          System.out.println("Nama Member dari Shelly Shop : "); 
            System.out.println("1.Kukung Kurniawan");
            System.out.println("1.Tane Yoroshi");
     
         }
    }
     
    public class Politic {
              private String name,address,born;
     
        public Politic(){}
        public Politic(String nama, String alamat, String ttl){
        this.name=nama;
        this.address=alamat;
        this.born=ttl;
        }
     
     
        public String getNamePolitic(){
        return name;
        }
        public String getAddressPolitic(){
        return address;
        }
        public String getBornPolitic(){
        return born;
        }
     
     
        void Become_fans(Artist artis2) {
     
        }
     
        public void Look_list_supporter(){
            System.out.println("List supporter for ---: ");
            System.out.println("1.Kukung Kurniawan");
     
     
        }
    }

    The Question : is my method of program that using oop okay? or should be re-build/
    if should, pls tell me the right construction...???

    should I use Array to save the name of the people that support politic, become fans artist, become member shop???
    if I should pls tell me the code.. I was confused...



    The problem : when => orang2.Become_fans(artis2);
    I want to display public void look_list_fans(){} that contain orang2 but I don't know how??

    when => orang2.Become_member(toko1);
    I want to display public void Look_list_member(){} that contain orang2 but I don't know how??
    Last edited by Ryo; February 29th, 2012 at 05:05 AM. Reason: For understanding the problem


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

    Do you have any questions about your program?
    Can you explain what your problem is?

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

    Ryo (February 26th, 2012)

  4. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Quote Originally Posted by Norm View Post
    Please Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

    Do you have any questions about your program?
    Can you explain what your problem is?
    Okay... its done... pls help me..

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    I cant make the program running just like above
    Please explain.
    Show the program's output and explain what is wrong with it and show what you want the output to be.

  6. #5
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    I got he problem at the method.
    that can add_friends, look_list_friend.etc..


    Output program that I wanted :

    List Fans from Amru Rizaldy :
    1.Tane Yoroshi
    2.Risman Rangga

    list support from Risman Rangga :
    1.Kukung Kurniawan

    list Member from Shelly Shop :
    1.Kukung Kurniawan
    2.Tane Yoroshi
    Last edited by Ryo; February 26th, 2012 at 05:39 PM.

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    What is the current output from the program?

    If you are getting compiler errors, they need to be fixed first.
    Copy and post the full text of the error messages here.

  8. #7
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Quote Originally Posted by Norm View Post
    What is the current output from the program?

    If you are getting compiler errors, they need to be fixed first.
    Copy and post the full text of the error messages here.
    Okay here is a thing,

    people orang1 = new people("Kukung Kurniawan","Sukabirus 26","29 Februari 1992");
    people orang2 = new people("Tane Yoroshi","Sukapura","22 Agustus 1990");

    how to save the people name,address, and born??

    when I wan to look at the poeple who joined the member shop??
    public void become_member(){} <= this is the problem,,

    I got no error but I got confused how to type the code that can save the people name and look
    the people who joined the shop.

  9. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    I got no error
    Please post your code that does not get any errors. The code you posted has many errors in it.

    how to save the people name,address, and born??
    The People class saves what is passed to it in class variables.

  10. #9
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Well pls check again I've updated it and got no error.. and read once again about the question and the problem

  11. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Ok, now it compiles and executes without errors and prints out this:
    List fans
    1.Tane Yoroshi
    2.Risman Rangga
    List supporter for ---:
    1.Kukung Kurniawan
    Nama Member dari Shelly Shop :
    1.Kukung Kurniawan
    1.Tane Yoroshi

    What next?

  12. #11
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Quote Originally Posted by Norm View Post
    Ok, now it compiles and executes without errors and prints out this:
    List fans
    1.Tane Yoroshi
    2.Risman Rangga
    List supporter for ---:
    1.Kukung Kurniawan
    Nama Member dari Shelly Shop :
    1.Kukung Kurniawan
    1.Tane Yoroshi

    What next?
    pls look at the people class there is a method : become_fans(Artist A){}
    and the class Artist method look_list_fans..

    what I was trying is to get the relation on that method, become_fans(){} save data people who fans the Artist,
    and the look_list_fans(){} is method that display the list of the fans,

    but I can't make it into a code program any advice or idea??

  13. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    What do you want the Become_fans() method to do with the argument that is passed to it?
    Should it save that argument in a list that the look_list_fans() method would use?

  14. #13
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Wink Re: NEED HELP TO FIX Object oriented Program Facebook

    I want to Become_fans(){} save the name of the people so the look_list_fans(){} coudl display it..
    Last edited by Ryo; February 29th, 2012 at 08:52 AM.

  15. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Yes that sounds like a way to do it.
    An ArrayList would be a good place to save the data.

  16. #15
    Junior Member
    Join Date
    Feb 2012
    Posts
    11
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    Quote Originally Posted by Norm View Post
    Yes that sounds like a way to do it.
    An ArrayList would be a good place to save the data.
    I have a question,, if I make the ArrayList in the become_fans(){} method, and save the name, how to pass the ArrayList to another mehtod (look_list_fans(){}) on another class?? I really need an example... would you mind helping me out...

  17. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: NEED HELP TO FIX Object oriented Program Facebook

    If the become_fans method saves the fans for an object, shouldn't the list_fans method be in the same object?
    If you make the list of fans a class member, then both the become_fans and the list_fans methods would be able to access the list of fans.

    If a class wants the fans for another class, then the class desiring the list of fans for the other class will have to call the class with the fans and get the list of fans from the class that has the fans.

    You need to decide what class should hold the list of fans.
    When you have that, then you need to provide methods to access that list.
    Last edited by Norm; February 29th, 2012 at 10:08 AM.

Similar Threads

  1. Object oriented programming
    By merr78 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 9th, 2012, 01:32 AM
  2. Object oriented programming
    By jonnitwo in forum Object Oriented Programming
    Replies: 8
    Last Post: September 2nd, 2011, 12:18 PM
  3. Object-oriented mess
    By mjpam in forum Object Oriented Programming
    Replies: 3
    Last Post: May 7th, 2011, 11:27 AM
  4. Object-oriented applet
    By mjpam in forum Object Oriented Programming
    Replies: 26
    Last Post: September 15th, 2010, 06:43 AM
  5. Object Oriented program, no output
    By boardbreaker in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 17th, 2009, 11:11 PM