나는 영화 프로젝트 시스템을 연습하고있다. Movie
클래스의 객체는 어떻게 표시합니까? 클래스 Movie
은 모두 movie
, movie1
, movie2
입니다.클래스의 객체를 표시하는 방법은 무엇입니까?
어떻게 동영상을 선택하고 하나의 방법 만 사용할 수 있습니까? 예를 들어 movie1
을 선택한 다음이 메소드를 실행합니다. movie1.dispMovie()
또는 메소드를 수동으로 실행해야합니까?
public class movie {
private String name;
private String desc;
private int year;
public static int movieNum = 0;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public void dispdesc(){
movieNum = movieNum + 1;
System.out.println("Movie #" + movieNum);
System.out.println("Title: " + getName());
System.out.println("Description: " + getDesc());
System.out.println("Year: " + getYear());
}
}
public class orangeBox {
public static void main(String[] args) {
movie up = new movie();
up.setName("Up");
up.setDesc("To avoid being taken away to a nursing home, an old widower tries to fly his home to Paradise Falls, South America, along with a boy scout who accidently lifted off with him. ");
up.setYear(2008);
up.dispdesc();
movie wallE = new movie();
wallE.setName("Wall-E");
wallE.setDesc("In the distant future, a small waste collecting robot inadvertently embarks on a space journey that will ultimately decide the fate of mankind.");
wallE.setYear(2008);
wallE.dispdesc();
}
}
메인 클래스에서 this.dispdesc()를 수행하지 않고 모든 동영상을 표시하는 메소드가 필요합니다.
편집
public class Store {
public static void main(String[] args) {
Movie up = new Movie();
up.setName("Up");
up.setDesc("To avoid being taken away...");
up.setYear(2009);
System.out.println(up);
}
}
코드를 표시하십시오. –
[Reflection] (http://docs.oracle.com/javase/tutorial/reflect/). – Maroun
@MarounMaroun - 질문을 오해 한 적이 있습니까? – TheLostMind