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??