From 2a28a070951c6a1f7ba5c6afb6f1bc25155f3e4b Mon Sep 17 00:00:00 2001 From: Yingjian Wang <yingjian.wang@mailbox.tu-dresden.de> Date: Wed, 19 Jan 2022 00:22:18 +0100 Subject: [PATCH] Update CanMove.jrag --- .../hanoi/{CanMove.jrag => GeneralInfo.jrag} | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) rename src/main/jastadd/hanoi/{CanMove.jrag => GeneralInfo.jrag} (84%) 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 46c4c3e..e984f01 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; + } +} -- GitLab