Skip to content
Snippets Groups Projects
Commit 9433860e authored by MAAZOUZ Ilyas's avatar MAAZOUZ Ilyas
Browse files

new

parent 93b339f8
No related branches found
No related tags found
No related merge requests found
Pipeline #17647 failed
......@@ -157,15 +157,15 @@ public class App {
}
}
public static String[] filter(String[] strings,StringFilter filter){
/*public static String[] filter(String[] strings,StringFilter filter){
for(int i=0;i<=strings.length;i++){
s
}
}*/
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@
public class Stack {
private Vector vector;
public Stack(int value){
this.vector=new Vector(value);
}
......@@ -19,8 +20,8 @@ public class Stack {
}
public int pop(){
int valeur = vector.get(vector.size());
vector.resize(vector.size()-1);
int valeur = this.vector.get(this.size());
this.vector.resize(this.vector.size()-1);
return valeur;
}
......
......@@ -86,7 +86,7 @@ public class Vector {
}
}
public int get(int index) {
if(index>=0 && this.size>=index){
if(index>=0){
return this.elements[index];
}
else return 0;
......
......@@ -33,19 +33,19 @@ public class StackTest {
}
@Test
void testEnsureCapacity_CapacityAlwaysIncreased() {
Vector vector = new Vector(120);
vector.ensureCapacity(10);
assertThat(vector.capacity()).isEqualTo(120);
public void testaddandpop() {
Stack stack1 = new Stack(10);
stack1.push(8);
stack1.push(8);
stack1.push(8);
System.out.println(stack1.pop());
}
@Test
void testEnsureCapacity_CapacitySatisfied() {
Vector vector = new Vector(23);
vector.ensureCapacity(120);
// TODO : add code
assertThat(vector.capacity()).isEqualTo(120);
void testisempty() {
Stack stack1 = new Stack(4);
assertThat(stack1.isEmpty()).isEqualTo(true);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment