as the question require to declare

// Creating Class Members
public class Films {
	private	String itemCode;
	private	String title;
	private	String description;
	private	String language;
	private	String runningTime;
	private	String productionCompany;
	private	String status; //eg, pending, premiering, running, written-off

    // No-argument Constructor: Without Parameters
    public Films() {
    	itemCode = "ABC12345";
    	title = "Jack English";
    	description = "Jack speaking English!";
    	language = "English";
    	runningTime = "1:30";
    	productionCompany = "Batu Caves";
    	status = "Pending";
    }
    
    // With Argument Constructor: With Parameters
    public Films(String itemCode, String title, String description, String language, String runningTime, String productionCompany, String status){
    	this.itemCode = itemCode;
    	this.title = title;
    	this.description = description;
    	this.language = language;
    	this.runningTime = runningTime;
    	this.productionCompany = productionCompany;
    	this.status = status;
    }

    //Copy Constructor
    public Films(Films films){
		itemCode = films.itemCode;
    	title = films.title;
    	description = films.description;
    	language = films.language;
    	runningTime = films.runningTime;
    	productionCompany = films.productionCompany;
    	status = films.status;    	
    }

and then the last part require us to use method equals that return true if two objects contain the same information,
here is my problem, what should i put the conditional?
i've tried;

public boolean equals(){
    	if(Films == Films)
    		return true;
    	else
    		return false;

The equals method requires one parameter, which is the object with which the current object is being compared. You use the fields of the two objects to decide whether you consider them to be equal or not.
eg You have a Person class. You consider two Person objects to be the same if the names and dates of birth are the same:

public boolean equals(Person other) {
  if (name.equals(other.name) & dob.equals(other.dob)) return true;
  else return false;
}
name.equals(other.name)

what is this mean?
i am confuese with this statement.

as my code above, if i want to add more films into the file by using array and create another .java file, how can i add more by using any looping method?
here is my tried.

P/S = change the Films class name to entity.

import java.util.Scanner;

public class collection {
	
	public static void main(String[] args){
		entity[] addFilms = new entity[100];
		int i = 0;
		Scanner scan = new Scanner(System.in);
		
		do{
			System.out.print("Item Code: ");
			addFilms[i].setItemCode() = scan.nextEntity();

alright, i take a look already, he's my classmate by the way haha. XD
i want to know why the scan.next() cannot put inside the setter method?
like film.setName(scan.next())

and i got one more problem, how can i call another class files method(not main)?
i post my code here what i've tried,


public static void main(String[] args){
    	Scanner scanMenu = new Scanner(System.in);
    	
    	System.out.println();
    	System.out.println("Ortsa Sdn. Bhd.");
    	System.out.println("---------------");
    	System.out.println("(1) Add New Film");
    	System.out.println("(2) Search Film");
    	System.out.println("(3) Amend Film");
    	System.out.println("(4) Update Film Status");
    	System.out.println("(5) Listing Films' Details");
    	System.out.println();
    	System.out.print("What's Your Choice: ");
    	int scanChoice = scanMenu.nextInt();
    	
    	if(scanChoice == 1)
    	collection.addFilm();    		
   		
    }
public void addFilm(entity[] films)

i was unable to call the addFilm method. :< why?

film.setName(scan.next())

scan.next()returns a String so that looks OK. Check the error message sagain, it's probably something else.

i was unable to call the addFilm method. :< why?

You need an instance of whatever class addFilm is defined in. What class is "collection" an instance of? Once again, check the exact error message.

your "instance" mean the addFilm's parameters?

i think the scan.next() put into the film.setItem(scan.next()) is okay already, maybe i make some mistake from that. :)
the addFilm error message is method addFilm in class collection cannot be applied to given types.
i've tried many ideas to solve this problem, but still fail. :/
P/S: the entity films array was declare in collection class file. :>

It doesn't have any parameters.
It's like the String class has a toUpperCase() method. To call that method you need an instance of String, as in myString.toUpperCase()
You seem to define addFilm in a class called "collection" (very confusing - class names should begin with a capital letter), so you need to create new Collection instance and use that to call addFilm.
The compiler will give you a detailed exact error message. If you don't understand it then post it here; don't just say "i was unable to call the addFilm method"

i think i got what you meaning already,
i think i know what's my problem already.
if i didn't call addFilm method in the Collection main so the entity main cannot call the addFilm method (mostly like in C calling method from main method), am i right?

import java.util.Scanner;

public class collection {
	
	public static void main(String[] args){
		entity[] films = new entity[100];
		addFilm(films);
	}

	//Add Film Method
	public static void addFilm(entity[] films){

one more questions, why i need to declare again the an array in entity class since my Collection class declared?

public static void main(String[] args){
    	entity[] ent = new entity[100];
    	Scanner scanMenu = new Scanner(System.in);
    	
    	System.out.println();
    	System.out.println("Ortsa Sdn. Bhd.");
    	System.out.println("---------------");
    	System.out.println("(1) Add New Film");
    	System.out.println("(2) Search Film");
    	System.out.println("(3) Amend Film");
    	System.out.println("(4) Update Film Status");
    	System.out.println("(5) Listing Films' Details");
    	System.out.println();
    	System.out.print("What's Your Choice: ");
    	int scanChoice = scanMenu.nextInt();
    	
    	if(scanChoice == 1)
    		collection.addFilm(ent);
    		
   		
    }

You seem to have changed addFilm to be static, which is one possible way to get round the previous problem, but not the best way. Anyway, now you can ignore my last few posts.
As for the second array, I have no idea why you have it. I don't understand why you pass an array to a method called addFilm. I would have expected something like
public void addFilm(Film f) {...

because the assignment is required us to declare an array in Collection class, so i must declare in collection class.
and, the addFilm method i have added static because i have to use the main to call it, otherwise compiler will error. :(

Yes, you need an array of Films (or equivalent) in the Collection class, but not anywhere else. NB You declare it inside main so it only exists as long as you are in that method - it would be better declared in the class but outside any one method so all the methods of the class have access to it.

It errors because you didn't create an instance, like I explained earlier.
By making it all static you commit to one Collection array per program - static means "one per class". If you make it instance based then you can have multiple collections, and do good stuff like:

FilmCollection filmsIOwn = new FilmCollection();
FilmCollection  filmsIWantToBuy = new FilmCollection();

void buyFilm(Film f) {
   filmsIOwn.addFilm(f);
   filmsIWantToBuy.removeFilm(f);
}

ps Collection is the name of an important Java API class, so its best not to use it for your own class.

alright, if i no misstaken, is should be like this

public class collection {
	entity[] films = new entity[100];

but i still got some doubt about how to call my collection class array to other class file?

You don't.
You create a new instance of collection, and you call its public methods to add a film etc etc. The entity[] array is part of how the collection class works, and should ideally be private.

hmm, i am not really understand it. but i post my problem code here and check for me where is my misstake, i'll think about it. :)

Class File

import java.util.Scanner;

public class collection {
	private entity[] films = new entity[100];
         public void addFilm(entity[] films)
              ...
         public void searchFilm(entity[] films)
              ...
         public entity[] getFilms(){
		return films;
	}
public class ClientProgram {

    public static void main(String[] args){
    	collection callCollection = new collection();
    	String[] mainArray = new String[callCollection.getFilms()];
public class collection {
  private entity[] films = new entity[100];
  public void addFilm(entity film) {
    films[nextAvailableArrayElement] = film
  }

Your collection already has an array of films ("entity" is a silly name; they are films) so you don't need anyone to supply one. Just pass in one film and let the collection class add it to the array it's already got

public void addFilm(){
		Scanner scan = new Scanner(System.in);
		char option = 'Y';

		System.out.println();
		System.out.println("Add New Films");
		System.out.println("=============");
		for(int i = 1; i < films.length && option == 'Y'; i++){
			System.out.print("Item Code: ");
			String code = scan.next();
				
		    System.out.print("Title: ");
		    String title = scan.next();
		    	
		    System.out.print("Description: ");
		    String description = scan.next();
		    	
		    System.out.print("Language: ");
		    String language = scan.next();
		    
		    System.out.print("Running Time(00:00): ");
		    String time = scan.next();
		    
		    System.out.print("Production Company: ");
		    String production = scan.next();
		    	
		    System.out.print("Status: ");
		    String status = scan.next();
		    	
			System.out.print("Add More?(Y/N) ");
			option = scan.next().toUpperCase().charAt(0);
			
			System.out.println();
			
			films[i] = new entity(code, title, description, language, time, production, status);
		}
	}

is this okay that my addFilm with empty arguments?

The confusion here is two meanings for "addFilm". The collection class needs one, just like I described. But in your main class you also have a method (the one you just posted) that prompts the user for data for a new Film.
Personally I would re-name that to public void inputFilm to avoid confusion.
So inputFilm prompts the user, creates a new Film object, and calls the collection's addFilm(Film f) method to add the new Film to the collection.
(I'm going out now, bye for now).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.