Hey,
I have another problem again...
This time I have to do stacks. This is a list, in which I can only put elements at the end fo the list and only get elemts from the end. So I have to write a programm which contains three main parts:
public class Stack
double[] array;
int number;
boolean yes;
boolean no;
public void length(int length)
//gives out the length of the array;
public boolean pop(int track)
//if the list is not full, put in the number and return yes;
//if the list is full, don't put the number into the list and return no;
public void push(int track)
//gives out the last element of the list, if list is not empty;
so that's what I have to do, I tried it and it would be nice if anyone could have a look over it and maybe help me to get it work, because i don't know exactly what to write in the public static void method()
public class Stack
{
double[] array;
int number;
boolean yes;
boolean no;
public void length(int length)
{
this.array = new double[length];
for(int i = 0; i < array.length; i++)
{
array[i] = Integer.MIN_VALUE;
}
}
public boolean pop(int track)
{
if(array[track] < array.length)
{
while(array[track] != Integer.MIN_VALUE)
{
track++;
}
array[track] = number;
return yes;
}
else
{
return no;
}
}
public void push(int track)
{
while(array[track] != number)
{
track++;
}
System.out.println(array[track]);
}
public static void main(String[] args)
{
Stack app = new Stack();
app.length(2);
}
}