The program already can compile and run. But, when we enter the film's code, an error will occurred. We had no idea how to solve it :\
public class Entity {
private String itemCode;
private String title;
private String description;
private int language;
private int time;
private String productCompany;
private int status;
public Entity(){
itemCode="E250";
title="The Lookout";
description="by Scott Frank";
language=1;
time=1900;
productCompany="BB Sdn. Bhd.";
status=1;
}
public Entity(String code, String title, String description, int language, int time, String company, int status) {
itemCode=code;
this.title=title;
this.description=description;
this.language=language;
this.time=time;
productCompany=company;
this.status=status;
}
public void setItemCode(String code){
itemCode=code;
}
public String getItemCode(){
return itemCode;
}
public void setTitle(String title){
this.title=title;
}
public String getTitle(){
return title;
}
public void setDescription(String description){
this.description=description;
}
public String getDescription(){
return description;
}
public void setLanguage(int language){
this.language=language;
}
public int getLanguage(){
return language;
}
public void setTime(int time){
this.time=time;
}
public int getTime(){
return time;
}
public void setProductCompany(String company){
productCompany=company;
}
public String getProductCompany(){
return productCompany;
}
public void setStatus(int status){
this.status=status;
}
public int getStatus(){
return status;
}
public static void CheckObject(Entity[] object,int a){
boolean test;
for(int i=0;i<a;i++){
if ((object[a].getItemCode()).equals(object[i].getItemCode())){
test=true;
System.out.println(test);}
else
test=false;
}
}
import java.util.Scanner;
public class Collection {
public static void main(String[] args) {
//add a film object to the arrays
Entity[] film=new Entity[100];
AddFilm(film);
for (int i=0; i<film.length; i++){
if (film[i]!=null){
System.out.println(film[i].getItemCode()+ film[i].getTitle() + film[i].getDescription()+ film[i].getLanguage()
+ film[i].getTime() + film[i].getProductCompany() + film[i].getStatus() );
}
}
}
public static void AddFilm(Entity[] film){
for(int i=0; i<film.length; i++){
if(film[i]==null){
Scanner scn=new Scanner(System.in);
System.out.print("Enter film's code :");
film[i].setItemCode(scn.next());
System.out.print("Enter film's title :");
film[i].setTitle(scn.next());
System.out.print("Enter film's description :");
film[i].setDescription(scn.next());
System.out.print("Select film's Language : \n1. English \n2. Malay \n3. Mandarin \n4. Indian \n5. Other \nChoose : ");
film[i].setLanguage(scn.nextInt());
System.out.print("Enter film's time (2400 hourse) :");
film[i].setTime(scn.nextInt());
System.out.print("Enter film production company name :");
film[i].setProductCompany(scn.next());
System.out.print("Select film's status :\n1. Pending \n2. Premiering \n3. Running \n4. Written-off \nSelection : ");
film[i].setStatus(scn.nextInt());
}
}
}
}