/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** * * @author Uwe Schmidt * * ein einfacher aber sicherer stack * implementiert als Unterklasse von SimpleStack * */ //-------------------- public class SafeStack extends SimpleStack { // keine neuen Datenfelder //-------------------- // die Konstruktoren public SafeStack(int max) { super(max); } //-------------------- public SafeStack() { super(); } //-------------------- /** * Lesen des obersten Elements */ public Object top() { assert preTop() : "Stack underflow"; return super.top(); } //-------------------- /** * oberstes Element loeschen */ public void pop() { assert preTop() : "Stack underflow"; super.pop(); } } //--------------------