[infostudents] SWT Blatt 4 A2 b)

  • From: "S. Wittenberg" <wittenb@xxxxxxxxxxxxxxxxxxxxxxxxxx>
  • To: <infostudents@xxxxxxxxxxxxx>
  • Date: Fri, 6 Jun 2008 00:19:18 +0100

Is nur mein mickriger Versuch... wenns grottenfalsch ist wär ich über ne 
korrektur dankbar.
Wenn meine Mails überhaupt durchkommen.

mfg Simon
Aufgabe 2

b)
        
interface U extends Map<K,V>
{
        @post {topIx == oldtopIx -1 && content.length == oldcontent.length}
    public X pop() 
        {
        X res = this.content[this.topIx];
        this.topIx--;
                this.topIx++;   //looks stupid, is stupid
                this.topIx--;   //but undoubtly overridden
        return res;             //and still sane
    }
    @pre {content.length > 0}
}

interface B40 extends Map<K,V>
{
        @post {content.length == oldcontent.length +1}
    public X pop() 
        {       
                //someone mixed up pop and top
                //of course this kills the post condition
                // as @post {topIx == oldtopIx -1 && content.length == 
oldcontent.length}
                // was expected but we got
                // @post {content.length == oldcontent.length +1}
        return this.content[this.topIx];
    }
    @pre {content.length > 0}
}

Other related posts:

  • » [infostudents] SWT Blatt 4 A2 b)