two arrays under one class

two arrays in one class? should i construct new class for those array?

Page 1 of 1

1 Replies - 719 Views - Last Post: 22 March 2009 - 02:24 PM Rate Topic: -----

#1 o0tomato0o  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-February 09

two arrays under one class

Posted 22 March 2009 - 02:06 PM

public class CustomerList
{
	public Customer[] customers;
	public Video[] videos;
.
.
.
.
customers = new Customer[100];
videos = new video[100];
.
.
.
.
videos[index] = new Video(title);


ok. my friend made this program (and it works too good) and i am not as smart as him..

my first question is... Customer[100].. it should mean that there's another class called Customer?

since its not String[] or int[] ...

2nd is.. if it does require another class called it, how should i write that seperate class?

so far i have..
public class Video 
{
	private Video[] video;
	

	public Video(int amt) 
	{
		 video = new Video[amt];
	}
well, something lyk that. not sure how to do yet.

Is This A Good Question/Topic? 0
  • +

Replies To: two arrays under one class

#2 AbuJaFaR  Icon User is offline

  • D.I.C Regular

Reputation: 13
  • View blog
  • Posts: 330
  • Joined: 13-December 07

Re: two arrays under one class

Posted 22 March 2009 - 02:24 PM

Yeap there is another class called Customer and another one called Video.

Its not required that these two classes will have an/or many arrays.U just define two arrays that are type Customer and type Video. (like String,int etc)
I dont know what u want to do but for example a Customer class could be like this.

class Customer{

String Name;
String lastName;
int Telephone;

public Customer(String n,String l,int t){ //constructor
 Name=n;
 lastName=l;
 Telephone=t;
}



After that u can add set/get's and etc.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1