-
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.
Tweaked file/class dependency ordering algorithm
- Loading branch information
thomashuston
committed
Dec 18, 2011
1 parent
ee1d084
commit 1bb0b5f
Showing
9 changed files
with
170 additions
and
63 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
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
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
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
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
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
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,63 @@ | ||
public class Magic { | ||
public static final Magic STOPPER = new Expelliarmus(); | ||
public static final Magic SLASHER = new Sectumsempra(); | ||
public static final Magic TORTURER = new Crucio(); | ||
|
||
public static void show(String s) { | ||
System.out.println(s); | ||
} | ||
|
||
public static void show(Magic m) { | ||
show(m.getClass().getName()); | ||
} | ||
|
||
public static Magic cast(Magic m) { | ||
return m; | ||
} | ||
|
||
public Magic cast() { | ||
return this; | ||
} | ||
|
||
public Magic counter(Magic m) { | ||
return STOPPER; | ||
} | ||
|
||
public static void main(String[] args) { | ||
show(STOPPER.counter(STOPPER)); | ||
show(STOPPER.counter(SLASHER)); | ||
show(SLASHER.counter(SLASHER)); | ||
show(TORTURER.counter(SLASHER)); | ||
show(new Sectumsempra().counter(SLASHER)); | ||
} | ||
} | ||
|
||
class Expelliarmus extends Magic { } | ||
|
||
class DarkMagic extends Magic { | ||
public static Magic cast(Magic m) { | ||
return m instanceof DarkMagic ? m : SLASHER; | ||
} | ||
|
||
public Magic counter(Magic m) { | ||
return cast(m); | ||
} | ||
|
||
public Magic counter(DarkMagic m) { | ||
return TORTURER; | ||
} | ||
} | ||
|
||
class Sectumsempra extends DarkMagic { | ||
public Magic cast() { | ||
return SLASHER; | ||
} | ||
} | ||
|
||
class UnforgivableCurse extends DarkMagic { } | ||
|
||
class Crucio extends UnforgivableCurse { | ||
public Magic counter(Magic m) { | ||
return TORTURER; | ||
} | ||
} |
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
Oops, something went wrong.