diff --git a/src/main/jastadd/hanoi/CanMove.jrag b/src/main/jastadd/hanoi/GeneralInfo.jrag similarity index 84% rename from src/main/jastadd/hanoi/CanMove.jrag rename to src/main/jastadd/hanoi/GeneralInfo.jrag index 46c4c3e1ce56f212271afa38ba319484a2486c37..e984f01b2f7368c79968220a9a087436118f9a3b 100644 --- a/src/main/jastadd/hanoi/CanMove.jrag +++ b/src/main/jastadd/hanoi/GeneralInfo.jrag @@ -1,27 +1,32 @@ -aspect CanMove { - uncache Disk.smallerThan(Disk D); - syn boolean Disk.smallerThan(Disk D) { - if(this.getSize() < D.getSize()){ - return true; - } - return false; - } - /*for odd turns, the smallest disk D0 is supposed to move in a certain sequence - to eventually move all the disks from P0 to P2. - Pillar.moveseq() return the integer who demonstrates the target pillar according to the sequence. - the sequence is 0 2 1... when the amount of disks is odd and 0 1 2... when even.*/ - uncache Pillar.moveSeq(); - inh int Pillar.moveSeq(); - eq Hanoi.getPillar(int i).moveSeq(){ - if(this.getAmountD()%2 == 1){ - return (i+2)%3; - }else{ - return (i+1)%3; - } - } - uncache Pillar.ID(); - inh int Pillar.ID(); - eq Hanoi.getPillar(int i).ID(){ - return i; - } -} \ No newline at end of file +aspect Info { + uncache Disk.smallerThan(Disk D); + syn boolean Disk.smallerThan(Disk D) { + if(this.getSize() < D.getSize()){ + return true; + } + return false; + } + /*for odd turns, the smallest disk D0 is supposed to move in a certain sequence + to eventually move all the disks from P0 to P2. + Pillar.moveseq() return the integer who demonstrates the target pillar according to the sequence. + the sequence is 0 2 1... when the amount of disks is odd and 0 1 2... when even.*/ + uncache Pillar.moveSeq(); + inh int Pillar.moveSeq(); + eq Hanoi.getPillar(int i).moveSeq(){ + if(this.getAmountD()%2 == 1){ + return (i+2)%3; + }else{ + return (i+1)%3; + } + } + uncache Pillar.AmountD(); + inh int Pillar.AmountD(); + eq Hanoi.getPillar(int i).AmountD(){ + return this.getAmountD(); + } + uncache Pillar.ID(); + inh int Pillar.ID(); + eq Hanoi.getPillar(int i).ID(){ + return i; + } +}