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.
Code java:
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??
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?
Re: NEED HELP TO FIX Object oriented Program Facebook
Quote:
Originally Posted by
Norm
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..
Re: NEED HELP TO FIX Object oriented Program Facebook
Quote:
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.
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
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.
Re: NEED HELP TO FIX Object oriented Program Facebook
Quote:
Originally Posted by
Norm
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.
Re: NEED HELP TO FIX Object oriented Program Facebook
Please post your code that does not get any errors. The code you posted has many errors in it.
Quote:
how to save the people name,address, and born??
The People class saves what is passed to it in class variables.
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
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?
Re: NEED HELP TO FIX Object oriented Program Facebook
Quote:
Originally Posted by
Norm
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??
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?
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..
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.
Re: NEED HELP TO FIX Object oriented Program Facebook
Quote:
Originally Posted by
Norm
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...
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.