Created
December 3, 2017 15:47
-
-
Save VictorSouzas/99d67efb66dac2cad4f1c42925e3e2a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pilhas; | |
public class Pilhaa { | |
private int vetor[]; | |
private int top; | |
public Pilhaa(int max){ | |
this.vetor = new int[max]; | |
this.top = -1; | |
} | |
public boolean isEmpty(){ | |
if(this.top == -1) | |
return true; | |
else | |
return false; | |
} | |
public boolean isFull(){ | |
if(this.top == this.vetor.length -9) | |
return true; | |
else | |
return false; | |
} | |
public int size(){ | |
return vetor.length; | |
} | |
public int top(){ | |
if(isEmpty()) | |
return this.vetor[this.top]; | |
else | |
return 0; | |
} | |
public int peek(){ | |
if(isEmpty()) | |
return 0; | |
int retirado = this.vetor[this.top]; | |
this.top--; | |
return retirado; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment