lab7
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
lab7 [2016/02/24 14:05] – created franck | lab7 [2018/03/11 23:19] (current) – franck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Consider | + | ====== Lab 7 ====== |
- | <html> | + | |
- | <pre> | + | In this lab, we consider a concurrent stack. |
- | public class ComputeSquareRoot | + | <code java> |
- | | + | /** |
- | | + | * A stack. |
- | System.out.println("The square root of " | + | * |
- | } | + | * @author |
+ | */ | ||
+ | public class Stack { | ||
+ | | ||
+ | private int size; | ||
+ | |||
+ | /* | ||
+ | * The maximal number of integers that can be stored in a stack. | ||
+ | */ | ||
+ | private final static | ||
+ | |||
+ | /** | ||
+ | * Initializes this stack to be empty. | ||
+ | */ | ||
+ | public Stack() { | ||
+ | this.content = new int[Stack.CAPACITY]; | ||
+ | this.size = 0; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Pushes the given integer onto this stack. | ||
+ | * | ||
+ | * @param value the integer to be pushed onto this stack. | ||
+ | */ | ||
+ | public void push(int value) { | ||
+ | | ||
+ | this.size++; | ||
+ | System.out.printf("Push %d\n", value); | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * 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(" | ||
+ | | ||
+ | | ||
} | } | ||
- | </pre> | + | </code> |
- | </html> | + | |
+ | 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> | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
- | - Develop a model class so that the above app can be verified with JPF. [[https:// | ||
- | - Develop a native peer so that the above app can be verified with JPF. | ||
lab7.1456322711.txt.gz · Last modified: 2016/02/24 14:05 by franck