-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding code for lab10 for feature models
along with results
- Loading branch information
Showing
40 changed files
with
862 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry excluding="COINS50.aj|QTR50.aj" kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GumballMachineV1</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>de.ovgu.featureide.core.extensibleFeatureProjectBuilder</name> | ||
<arguments> | ||
<dictionary> | ||
<key>build</key> | ||
<value>src</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>composer</key> | ||
<value>de.ovgu.featureide.core.composer.aspectj</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>equations</key> | ||
<value>configs</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>source</key> | ||
<value>src</value> | ||
</dictionary> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.ajdt.core.ajbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.ajdt.ui.ajnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>de.ovgu.featureide.core.featureProjectNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
QTR25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<featureModel> | ||
<properties/> | ||
<struct> | ||
<or abstract="true" mandatory="true" name="GumballMachine"> | ||
<description> | ||
|
||
</description> | ||
<alt abstract="true" mandatory="true" name="Base"> | ||
<description> | ||
|
||
</description> | ||
<and abstract="true" mandatory="true" name="C25"> | ||
<description> | ||
|
||
</description> | ||
<feature mandatory="true" name="QTR25"> | ||
<description> | ||
|
||
</description> | ||
</feature> | ||
</and> | ||
<alt abstract="true" mandatory="true" name="C50"> | ||
<description> | ||
|
||
</description> | ||
<feature mandatory="true" name="QTR50"> | ||
<description> | ||
|
||
</description> | ||
</feature> | ||
<feature mandatory="true" name="COINS50"> | ||
<description> | ||
|
||
</description> | ||
</feature> | ||
</alt> | ||
</alt> | ||
</or> | ||
</struct> | ||
<constraints/> | ||
<calculations Auto="true" Constraints="true" Features="true" Redundant="true" Tautology="true"/> | ||
<comments/> | ||
<featureOrder userDefined="false"/> | ||
</featureModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
public aspect COINS50 { | ||
|
||
// implement advice for getTenant | ||
Object around(GumballMachine m) : target(m) && call(String GumballMachine.getTenant(..)) { | ||
return "COINS50" ; | ||
} | ||
|
||
// implement advice for insertQuarter | ||
after(GumballMachine m): target(m) && call(void GumballMachine.insertQuarter(..)) { | ||
if (m.getCoinValue() < 50) { | ||
m.setCoinValue(m.getCoinValue() + 25); | ||
System.out.println("A quarter has been inserted"); | ||
} else { | ||
System.out.println("There are already quarters in the slot"); | ||
} | ||
} | ||
|
||
|
||
// implement advice for insertCoin | ||
after(GumballMachine m): target(m) && call(void GumballMachine.insertCoin(..)) { | ||
Object[] args = thisJoinPoint.getArgs(); | ||
int value = ((Integer) args[0]).intValue() ; | ||
if (m.getCoinValue() < 50) { | ||
m.setCoinValue(m.getCoinValue() + value); | ||
System.out.println( value + " cents has been inserted"); | ||
} else { | ||
System.out.println("There are already 50 cents in the slot"); | ||
} | ||
} | ||
|
||
// implement advice for turnTheCrank | ||
after(GumballMachine m): target(m) && call(void GumballMachine.turnTheCrank(..)) { | ||
if (m.getCoinValue() == 50) { | ||
m.setCoinValue(0); | ||
if (m.getCount() > 0) { | ||
System.out.println("Here is your Gumball! Enjoy!"); | ||
m.setCount(m.getCount() - 1); | ||
} else { | ||
System.out.println("Sorry! We're out of Gumballs!"); | ||
} | ||
} else { | ||
System.out.println("Crank will not turn without enough Coins!"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
public class GumballMachine { | ||
|
||
private int cnt = 0; | ||
private boolean quarterInSlot = false; | ||
private int coinValue = 0; | ||
|
||
public String getTenant() { | ||
return null ; | ||
} | ||
|
||
public int getCoinValue() { | ||
return coinValue; | ||
} | ||
|
||
public void setCoinValue(int v) { | ||
this.coinValue = v; | ||
} | ||
|
||
public boolean isQuarterInSlot() { | ||
return quarterInSlot; | ||
} | ||
|
||
public void setQuarterInSlot(boolean q) { | ||
this.quarterInSlot = q; | ||
} | ||
|
||
public GumballMachine(int count) { | ||
this.cnt = count; | ||
} | ||
|
||
public void insertQuarter() { | ||
System.out.println( "==> Insert Quarter <==" ) ; | ||
} | ||
|
||
public void insertCoin(Integer value) { | ||
System.out.println( "==> Insert Coin " + value.toString() + " <==" ) ; | ||
} | ||
|
||
public void turnTheCrank() { | ||
System.out.println( "==> Turn Crank <==" ) ; | ||
} | ||
|
||
public int getCount() { | ||
return cnt; | ||
} | ||
|
||
public void setCount(int c) { | ||
cnt = c; | ||
} | ||
|
||
public static void main(String[] args) { | ||
GumballMachine m = new GumballMachine(2); | ||
System.out.println("*** Gumball Machine " + m.getTenant() + " *** "); | ||
m.insertQuarter(); | ||
m.turnTheCrank(); // should eject for tenant #1 | ||
m.insertQuarter(); | ||
m.turnTheCrank(); // should eject for tenant #1, #2, and #3 | ||
m.insertCoin(10); | ||
m.insertCoin(10); | ||
m.insertCoin(5); | ||
m.insertCoin(25); | ||
m.turnTheCrank(); // should eject for tenant #3 | ||
m.insertCoin(10); | ||
m.insertCoin(10); | ||
m.turnTheCrank(); // should eject for tenant #3 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
public aspect QTR25 { | ||
|
||
// implement advice for getTenant | ||
Object around(GumballMachine m) : target(m) && call(String GumballMachine.getTenant(..)) { | ||
return "QTR25" ; | ||
} | ||
|
||
// implement advice for insertQuarter | ||
after(GumballMachine m): target(m) && call(void GumballMachine.insertQuarter(..)) { | ||
if ( !m.isQuarterInSlot() ) { | ||
m.setQuarterInSlot( true ); | ||
System.out.println("A quarter has been inserted"); | ||
} else { | ||
System.out.println("There's already a quarter in the slot"); | ||
} | ||
} | ||
|
||
// implement advice for turnTheCrank | ||
after(GumballMachine m): target(m) && call(void GumballMachine.turnTheCrank(..)) { | ||
if (m.isQuarterInSlot()) { | ||
m.setQuarterInSlot( false ) ; | ||
if (m.getCount() > 0) { | ||
System.out.println("Here is your Gumball! Enjoy!"); | ||
m.setCount(m.getCount()-1); | ||
} else { | ||
System.out.println("Sorry! We're out of Gumballs!"); | ||
} | ||
} else { | ||
System.out.println("Crank will not turn without a Quarter!"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
public aspect QTR50 { | ||
|
||
// implement advice for getTenant | ||
Object around(GumballMachine m) : target(m) && call(String GumballMachine.getTenant(..)) { | ||
return "QTR50" ; | ||
} | ||
|
||
// implement advice for insertQuarter | ||
after(GumballMachine m): target(m) && call(void GumballMachine.insertQuarter(..)) { | ||
if (m.getCoinValue() < 50) { | ||
m.setCoinValue(m.getCoinValue() + 25); | ||
System.out.println("A quarter has been inserted"); | ||
} else { | ||
System.out.println("There are already quarters in the slot"); | ||
} | ||
} | ||
|
||
// implement advice for turnTheCrank | ||
after(GumballMachine m): target(m) && call(void GumballMachine.turnTheCrank(..)) { | ||
if (m.getCoinValue() == 50) { | ||
m.setCoinValue(0); | ||
if (m.getCount() > 0) { | ||
System.out.println("Here is your Gumball! Enjoy!"); | ||
m.setCount(m.getCount() - 1); | ||
} else { | ||
System.out.println("Sorry! We're out of Gumballs!"); | ||
} | ||
} else { | ||
System.out.println("Crank will not turn without enough Quarters!"); | ||
} | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry excluding="ONEQTR.aj|COST25.aj|TWOQTR.aj|CRANKMODEL.aj" kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GumballMachineV2</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>de.ovgu.featureide.core.extensibleFeatureProjectBuilder</name> | ||
<arguments> | ||
<dictionary> | ||
<key>build</key> | ||
<value>src</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>composer</key> | ||
<value>de.ovgu.featureide.core.composer.aspectj</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>equations</key> | ||
<value>configs</value> | ||
</dictionary> | ||
<dictionary> | ||
<key>source</key> | ||
<value>src</value> | ||
</dictionary> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.ajdt.core.ajbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.ajdt.ui.ajnature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>de.ovgu.featureide.core.featureProjectNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SLOTMODEL | ||
COST50 |
Oops, something went wrong.