diff --git a/DTRAM/src/strategy/DragonSlayer.java b/DTRAM/src/strategy/DragonSlayer.java new file mode 100644 index 0000000..b5eba83 --- /dev/null +++ b/DTRAM/src/strategy/DragonSlayer.java @@ -0,0 +1,18 @@ +package strategy; + +import java.util.*; + +public class DragonSlayer { + private MeleeStrategy meleeStrategy; + private SpellStrategy spellStrategy; + private ProjectileStrategy projectileStrategy; + private Map.Entry value = new AbstractMap.SimpleEntry<>(0, "none"); + public DragonSlayer(MeleeStrategy meleeStrategy, SpellStrategy spellStrategy, ProjectileStrategy projectileStrategy) { + this.meleeStrategy = meleeStrategy; + this.spellStrategy = spellStrategy; + this.projectileStrategy = projectileStrategy; + } + public Map.Entry getValue() { + return new AbstractMap.SimpleEntry<>(value); + } +} \ No newline at end of file diff --git a/DTRAM/src/strategy/MeleeStrategy.java b/DTRAM/src/strategy/MeleeStrategy.java new file mode 100644 index 0000000..ad33d17 --- /dev/null +++ b/DTRAM/src/strategy/MeleeStrategy.java @@ -0,0 +1,19 @@ +package strategy; + +import java.util.*; + +public class MeleeStrategy { + private Map.Entry value = new AbstractMap.SimpleEntry<>(1, "WithYourExcaliburYouSeverTheDragon'sHead!"); + public void updateDragonSlayer(Map.Entry dragonSlayer) { + Map.Entry temp_if3; + if ((this.value.getKey()==dragonSlayer.getKey())) { + temp_if3 = this.value; + } else { + temp_if3 = new AbstractMap.SimpleEntry<>(0, "none"); + } + value = temp_if3; + } + public Map.Entry getValue() { + return new AbstractMap.SimpleEntry<>(value); + } +} \ No newline at end of file diff --git a/DTRAM/src/strategy/ProjectileStrategy.java b/DTRAM/src/strategy/ProjectileStrategy.java new file mode 100644 index 0000000..7ec2c15 --- /dev/null +++ b/DTRAM/src/strategy/ProjectileStrategy.java @@ -0,0 +1,19 @@ +package strategy; + +import java.util.*; + +public class ProjectileStrategy { + private Map.Entry value = new AbstractMap.SimpleEntry<>(2, "YouShootTheDragonWithTheMagicalCrossbowAndItFallsDeadOnTheGround!"); + public void updateDragonSlayer(Map.Entry dragonSlayer) { + Map.Entry temp_if5; + if ((this.value.getKey()==dragonSlayer.getKey())) { + temp_if5 = this.value; + } else { + temp_if5 = new AbstractMap.SimpleEntry<>(0, "none"); + } + value = temp_if5; + } + public Map.Entry getValue() { + return new AbstractMap.SimpleEntry<>(value); + } +} \ No newline at end of file diff --git a/DTRAM/src/strategy/SpellStrategy.java b/DTRAM/src/strategy/SpellStrategy.java new file mode 100644 index 0000000..d1b07e0 --- /dev/null +++ b/DTRAM/src/strategy/SpellStrategy.java @@ -0,0 +1,19 @@ +package strategy; + +import java.util.*; + +public class SpellStrategy { + private Map.Entry value = new AbstractMap.SimpleEntry<>(3, "YouCastTheSpellOfDisintegrationAndTheDragonVaporizesInAPileOfDust!"); + public void updateDragonSlayer(Map.Entry dragonSlayer) { + Map.Entry temp_if4; + if ((this.value.getKey()==dragonSlayer.getKey())) { + temp_if4 = this.value; + } else { + temp_if4 = new AbstractMap.SimpleEntry<>(0, "none"); + } + value = temp_if4; + } + public Map.Entry getValue() { + return new AbstractMap.SimpleEntry<>(value); + } +} \ No newline at end of file diff --git a/DTRAM/src/strategy/Strategy.java b/DTRAM/src/strategy/Strategy.java new file mode 100644 index 0000000..3df2a7c --- /dev/null +++ b/DTRAM/src/strategy/Strategy.java @@ -0,0 +1,28 @@ +package strategy; + +import java.util.*; + +public class Strategy { + private MeleeStrategy meleeStrategy; + private SpellStrategy spellStrategy; + private ProjectileStrategy projectileStrategy; + private DragonSlayer dragonSlayer; + public Strategy() { + meleeStrategy = new MeleeStrategy(); + spellStrategy = new SpellStrategy(); + projectileStrategy = new ProjectileStrategy(); + dragonSlayer = new DragonSlayer(meleeStrategy,spellStrategy,projectileStrategy); + } + public Map.Entry getProjectileStrategy() { + return projectileStrategy.getValue(); + } + public Map.Entry getSpellStrategy() { + return spellStrategy.getValue(); + } + public Map.Entry getMeleeStrategy() { + return meleeStrategy.getValue(); + } + public Map.Entry getDragonSlayer() { + return dragonSlayer.getValue(); + } +} \ No newline at end of file diff --git a/models/Adapter.model b/models/Adapter.model deleted file mode 100644 index b78e32f..0000000 --- a/models/Adapter.model +++ /dev/null @@ -1,18 +0,0 @@ -init{ - fishingBoat := "TheFishingBoatIsSailing" -} - -channel CIO{ - out captain(cp:Str, row(s:Str)) == s -} - -channel C1{ - in captain(cp1:Str, row(s2)) == s2 - out fishingBoatAdapter(fa:Str, sail(s2)) == s2 -} - -channel C2{ - in fishingBoatAdapter(fa2:Str, sail(s3)) == s3 - out fishingBoat(fb2:Str, sail(s3)) == s3 -} - diff --git a/models/Bridge.model b/models/Bridge.model deleted file mode 100644 index f77e4a8..0000000 --- a/models/Bridge.model +++ /dev/null @@ -1,26 +0,0 @@ -init{ - sword := "sword" - hammer := "hammer" - flyingEnchantment := "TheItemBeginsToGlowFaintly." - soulEatingEnchantment := "TheItemSpreadsBloodlust." -} - -channel CS2F{ - in sword(s:Str, wield(s2:Str)) == s2 - out flyingEnchantment(fe:Str, wield(s2)) == fe -} - -channel CS2S{ - in sword(s:Str, wield(s2)) == s2 - out soulEatingEnchantment(se:Str, wield(s2)) == se -} - -channel CH2F{ - in hammer(h:Str, wield(h2:Str)) == h2 - out flyingEnchantment(fe:Str, wield(h2)) == fe -} - -channel CH2S{ - in hammer(h:Str, wield(h2)) == h2 - out soulEatingEnchantment(se, wield(h2)) == se -} \ No newline at end of file diff --git a/models/Builder.model b/models/Builder.model deleted file mode 100644 index 85fa2df..0000000 --- a/models/Builder.model +++ /dev/null @@ -1,8 +0,0 @@ -channel CIO{ - out Builder(n1:Int, setName(n:Int)) == 1 -} - -channel Build{ - in Builder(n2, build(n2:Int)) == 1 - out Hero(h:Int, build(n2)) == 1 -} \ No newline at end of file diff --git a/models/Decorator.model b/models/Decorator.model deleted file mode 100644 index a31845d..0000000 --- a/models/Decorator.model +++ /dev/null @@ -1,4 +0,0 @@ -channel C1{ - in simpleTroll(st2:Int, updatePower(power)) == power - out clubbedTroll(ct:Int, updatePower(power)) == power + 10 -} \ No newline at end of file diff --git a/models/Iterator.model b/models/Iterator.model deleted file mode 100644 index 910c571..0000000 --- a/models/Iterator.model +++ /dev/null @@ -1,8 +0,0 @@ -channel CIO{ - out treasureChest(items, getItems(itemType:Str)) == pair(0,0) -} - -channel C1{ - in treasureChest(i2, getItems(itemType)) == pair(0,0) - out treasureIterator(itemName:Str, getItems(itemType)) == itemName -} \ No newline at end of file diff --git a/models/Memento.model b/models/Memento.model deleted file mode 100644 index 8703d4d..0000000 --- a/models/Memento.model +++ /dev/null @@ -1,4 +0,0 @@ -channel CIO1{ - out star(s:Tuple, timePasses(nil)) == tuple(starType:Str, tuple(years:Int,mass:Int)) -} - diff --git a/models/Observer.model b/models/Observer.model deleted file mode 100644 index 573ec04..0000000 --- a/models/Observer.model +++ /dev/null @@ -1,20 +0,0 @@ -init{ - weather := 0 - logger := "not_started" -} - -channel CIO1{ - out weather(time:Int, timePasses(nil)) == mod(time + 1,4) -} - -channel CIO2{ - out orcs(o:Int, update(weather)) == weather - out hobbits(h:Int, update(weather)) == weather -} - -channel C1{ - in weather(w:Int, update(weather)) == weather - out orcs(o2:Int, update(weather)) == weather - out hobbits(h2:Int, update(weather)) == weather -} - diff --git a/models/Proxy.model b/models/Proxy.model deleted file mode 100644 index a60f8fb..0000000 --- a/models/Proxy.model +++ /dev/null @@ -1,9 +0,0 @@ -channel CIO{ - out wizardTowerProxy(wtp:Int, enter(wizard:Str)) == wtp -} - -channel C1{ - in wizardTowerProxy(wtp2:Int, enter(wizard)) == wizard - out ivoryTower(it:Int, enter(wizard)) == if(eq(it,3), it + 1, it) -} - diff --git a/models/behavioral/Iterator.model b/models/behavioral/Iterator.model new file mode 100644 index 0000000..910c571 --- /dev/null +++ b/models/behavioral/Iterator.model @@ -0,0 +1,8 @@ +channel CIO{ + out treasureChest(items, getItems(itemType:Str)) == pair(0,0) +} + +channel C1{ + in treasureChest(i2, getItems(itemType)) == pair(0,0) + out treasureIterator(itemName:Str, getItems(itemType)) == itemName +} \ No newline at end of file diff --git a/models/behavioral/Memento.model b/models/behavioral/Memento.model new file mode 100644 index 0000000..8703d4d --- /dev/null +++ b/models/behavioral/Memento.model @@ -0,0 +1,4 @@ +channel CIO1{ + out star(s:Tuple, timePasses(nil)) == tuple(starType:Str, tuple(years:Int,mass:Int)) +} + diff --git a/models/behavioral/Observer.model b/models/behavioral/Observer.model new file mode 100644 index 0000000..573ec04 --- /dev/null +++ b/models/behavioral/Observer.model @@ -0,0 +1,20 @@ +init{ + weather := 0 + logger := "not_started" +} + +channel CIO1{ + out weather(time:Int, timePasses(nil)) == mod(time + 1,4) +} + +channel CIO2{ + out orcs(o:Int, update(weather)) == weather + out hobbits(h:Int, update(weather)) == weather +} + +channel C1{ + in weather(w:Int, update(weather)) == weather + out orcs(o2:Int, update(weather)) == weather + out hobbits(h2:Int, update(weather)) == weather +} + diff --git a/models/behavioral/Strategy.model b/models/behavioral/Strategy.model new file mode 100644 index 0000000..39f942c --- /dev/null +++ b/models/behavioral/Strategy.model @@ -0,0 +1,21 @@ +init{ + dragonSlayer := tuple(0, "none") + meleeStrategy := tuple(1, "WithYourExcaliburYouSeverTheDragon'sHead!") + projectileStrategy := tuple(2, "YouShootTheDragonWithTheMagicalCrossbowAndItFallsDeadOnTheGround!") + spellStrategy := tuple(3,"YouCastTheSpellOfDisintegrationAndTheDragonVaporizesInAPileOfDust!") +} + +channel CD2M{ + in dragonSlayer(ds:Tuple, changeStrategy(id:Int,strategy:Str)) == tuple(id,strategy) + out meleeStrategy(ms:Tuple, changeStrategy(id,strategy)) == if(eq(fst(ms),id),ms,tuple(0,"none")) +} + +channel CD2S{ + in dragonSlayer(ds:Tuple, changeStrategy(id, strategy)) == tuple(id,strategy) + out spellStrategy(sp:Tuple, changeStrategy(id, strategy)) == if(eq(fst(sp),id),sp,tuple(0,"none")) +} + +channel CD2P{ + in dragonSlayer(ds:Tuple, changeStrategy(id,strategy)) == tuple(id,strategy) + out projectileStrategy(pr:Tuple, changeStrategy(id,strategy)) == if(eq(fst(pr),id),pr,tuple(0,"none")) +} diff --git a/models/creational/Builder.model b/models/creational/Builder.model new file mode 100644 index 0000000..85fa2df --- /dev/null +++ b/models/creational/Builder.model @@ -0,0 +1,8 @@ +channel CIO{ + out Builder(n1:Int, setName(n:Int)) == 1 +} + +channel Build{ + in Builder(n2, build(n2:Int)) == 1 + out Hero(h:Int, build(n2)) == 1 +} \ No newline at end of file diff --git a/models/structual/Adapter.model b/models/structual/Adapter.model new file mode 100644 index 0000000..b78e32f --- /dev/null +++ b/models/structual/Adapter.model @@ -0,0 +1,18 @@ +init{ + fishingBoat := "TheFishingBoatIsSailing" +} + +channel CIO{ + out captain(cp:Str, row(s:Str)) == s +} + +channel C1{ + in captain(cp1:Str, row(s2)) == s2 + out fishingBoatAdapter(fa:Str, sail(s2)) == s2 +} + +channel C2{ + in fishingBoatAdapter(fa2:Str, sail(s3)) == s3 + out fishingBoat(fb2:Str, sail(s3)) == s3 +} + diff --git a/models/structual/Bridge.model b/models/structual/Bridge.model new file mode 100644 index 0000000..f77e4a8 --- /dev/null +++ b/models/structual/Bridge.model @@ -0,0 +1,26 @@ +init{ + sword := "sword" + hammer := "hammer" + flyingEnchantment := "TheItemBeginsToGlowFaintly." + soulEatingEnchantment := "TheItemSpreadsBloodlust." +} + +channel CS2F{ + in sword(s:Str, wield(s2:Str)) == s2 + out flyingEnchantment(fe:Str, wield(s2)) == fe +} + +channel CS2S{ + in sword(s:Str, wield(s2)) == s2 + out soulEatingEnchantment(se:Str, wield(s2)) == se +} + +channel CH2F{ + in hammer(h:Str, wield(h2:Str)) == h2 + out flyingEnchantment(fe:Str, wield(h2)) == fe +} + +channel CH2S{ + in hammer(h:Str, wield(h2)) == h2 + out soulEatingEnchantment(se, wield(h2)) == se +} \ No newline at end of file diff --git a/models/structual/Decorator.model b/models/structual/Decorator.model new file mode 100644 index 0000000..a31845d --- /dev/null +++ b/models/structual/Decorator.model @@ -0,0 +1,4 @@ +channel C1{ + in simpleTroll(st2:Int, updatePower(power)) == power + out clubbedTroll(ct:Int, updatePower(power)) == power + 10 +} \ No newline at end of file diff --git a/models/structual/Proxy.model b/models/structual/Proxy.model new file mode 100644 index 0000000..a60f8fb --- /dev/null +++ b/models/structual/Proxy.model @@ -0,0 +1,9 @@ +channel CIO{ + out wizardTowerProxy(wtp:Int, enter(wizard:Str)) == wtp +} + +channel C1{ + in wizardTowerProxy(wtp2:Int, enter(wizard)) == wizard + out ivoryTower(it:Int, enter(wizard)) == if(eq(it,3), it + 1, it) +} +