lab7
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| lab7 [2018/03/11 23:19] – franck | lab7 [2020/02/25 19:35] (current) – franck | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Lab 7 ====== | + | ====== Lab 4 ====== |
| - | In this lab, we consider a concurrent stack. | + | Test the listener gov.nasa.jpf.StackDepthChecker. |
| - | <code java> | + | |
| - | /** | + | |
| - | * A stack. It stores integers. | + | |
| - | * | + | |
| - | * @author | + | |
| - | */ | + | |
| - | public class Stack { | + | |
| - | private int[] content; | + | |
| - | private int size; | + | |
| - | + | ||
| - | /* | + | |
| - | * The maximal number of integers that can be stored in a stack. | + | |
| - | */ | + | |
| - | private final static int CAPACITY = 5; | + | |
| - | + | ||
| - | /** | + | |
| - | * Initializes this stack to be empty. | + | |
| - | */ | + | |
| - | public Stack() { | + | |
| - | this.content = new int[Stack.CAPACITY]; | + | |
| - | this.size = 0; | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Pushes | + | |
| - | * | + | |
| - | * @param value the integer to be pushed onto this stack. | + | |
| - | */ | + | |
| - | public void push(int value) { | + | |
| - | this.content[this.size] = value; | + | |
| - | this.size++; | + | |
| - | System.out.printf(" | + | |
| - | } | + | |
| - | + | ||
| - | /** | + | |
| - | * Pops the top of this stack and returns the integer. | + | |
| - | * | + | |
| - | * @return the top of this stack. | + | |
| - | */ | + | |
| - | public int pop() { | + | |
| - | this.size--; | + | |
| - | int value = this.content[this.size]; | + | |
| - | System.out.printf(" | + | |
| - | return value; | + | |
| - | } | + | |
| - | } | + | |
| - | </ | + | |
| - | + | ||
| - | Implement the following classes. | + | |
| - | * The class Pusher. | + | |
| - | * The class Stack. | + | |
| - | * The class Main. This class only contains a main method. | + | |
| - | + | ||
| - | To receive feedback, submit your code using the submit command:\\ | + | |
| < | < | ||
| - | submit 4315 lab7 <name of class> | + | submit 4315 lab4 <name of class> |
| </ | </ | ||
lab7.1520810377.txt.gz · Last modified: by franck
