NaN:NaN
NaN:NaN
--:-- / --:--
Newgrounds Background Image Theme

DuntMan just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

array instruction...

757 Views | 7 Replies
New Topic Respond to this Topic

array instruction... Mar 9, 2006


wazzap guys, look... im pretty n00b at programming and i've found this little line of code that i can't undertstand, i'ts a syntaxis problem so i only need you to tell me what it does

return array[(end + 1 + n) % array.length];

i know what a return is and i understand everything abourt asignations, arrays and stuff. but i have been programming in java lenguaje only for 2 months

tnxs in advanced

Response to array instruction... Mar 9, 2006


Which language? Many languages have very similar syntax and without knowing which one exclusively, it's hard to say what you should be using.


Merkd.com - It Pays to Play

Earn real money by betting and investing; or, sponsor, challenge, compete,

recruit, communicate, network, earn money playing games, and much more.

Response to array instruction... Mar 9, 2006


At 3/9/06 08:03 PM, Cris7ian wrote: wazzap guys, look... im pretty n00b at programming and i've found this little line of code that i can't undertstand, i'ts a syntaxis problem so i only need you to tell me what it does

return array[(end + 1 + n) % array.length];

i know what a return is and i understand everything abourt asignations, arrays and stuff. but i have been programming in java lenguaje only for 2 months

tnxs in advanced

We would really have to know what was in "array", and what the value of "end" and "n" are to help you.

Response to array instruction... Mar 9, 2006


At 3/9/06 08:39 PM, Pilot-Doofy wrote: Which language? Many languages have very similar syntax and without knowing which one exclusively, it's hard to say what you should be using.

He said Java.

Response to array instruction... Mar 9, 2006


At 3/9/06 08:39 PM, Pilot-Doofy wrote: Which language? Many languages have very similar syntax and without knowing which one exclusively, it's hard to say what you should be using.

:but i have been programming in java lenguaje only for 2 months

.

Response to array instruction... Mar 9, 2006


At 3/9/06 08:39 PM, whatthedeuce wrote::

We would really have to know what was in "array", and what the value of "end" and "n" are to help you.

im talking about a array list, you know, an unlimited array so to speak, i understand perfectly how it works but i dont understant the % function, i havent seen it in my class (college class of course) i dont need an explanation bout what a list is, only need to know the role of the % carachter in the instruction, im not that familiar with java.

heres the code anyway

public class pArrayList{
protected Object[] array;
protected int start,end,number;

public pArrayList(int maxsize){
array = new Object[maxsize];
start = end = number = 0;
}
public boolean isEmpty(){
return number == 0;
}
public boolean isFull(){
return number >= array.length;
}
public int size(){
return number;
}
public void insert(Object o){
if(number < array.length){
array[start = (++start % array.length)] = o;
number++;
}
}
public void insertEnd(Object o){
if(number < array.length){
array[end] = o;
end = (--end + array.length) % array.length;
number++;
}
}
public Object remove(){
if(isEmpty())
return null;
number--;
int i = start;
start = (--start + array.length) % array.length;
return array[i];
}
public Object removeEnd(){
if(isEmpty())
return null;
number--;
return array[end = (++end % array.length)];
}
public Object peek(int n){
if(n >= number)
return null;
return array[(end + 1 + n) % array.length];
}
}

Response to array instruction... Mar 9, 2006


Modular division, basically the remainder of (array[(end + 1 + n) / array.length)

Response to array instruction... Mar 9, 2006


At 3/9/06 09:39 PM, 0x41 wrote: Modular division, basically the remainder of (array[(end + 1 + n) / array.length)

thanks dude!

a mod b

of course!