diff options
Diffstat (limited to 'docs/teaching/exercises/answers')
-rw-r--r-- | docs/teaching/exercises/answers/Answer1d.java | 23 | ||||
-rw-r--r-- | docs/teaching/exercises/answers/Answer3a.java | 6 | ||||
-rw-r--r-- | docs/teaching/exercises/answers/Answer3b.java | 9 | ||||
-rw-r--r-- | docs/teaching/exercises/answers/Answer3c.java | 18 |
4 files changed, 12 insertions, 44 deletions
diff --git a/docs/teaching/exercises/answers/Answer1d.java b/docs/teaching/exercises/answers/Answer1d.java deleted file mode 100644 index 1aa74e79b..000000000 --- a/docs/teaching/exercises/answers/Answer1d.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * PARC initial implementation - * ******************************************************************/ - -package answers; - -aspect Answer1c { - declare error - : set(private * *) - && !(withincode(* set*(..)) - || withincode(new(..)) - || withincode(void figures.Point.move(int, int))) - && within(figures.*) - : "bad field set"; -} diff --git a/docs/teaching/exercises/answers/Answer3a.java b/docs/teaching/exercises/answers/Answer3a.java index fc5e1d3f7..3bbfb1e98 100644 --- a/docs/teaching/exercises/answers/Answer3a.java +++ b/docs/teaching/exercises/answers/Answer3a.java @@ -14,10 +14,8 @@ package answers; import support.Log; -import figures.Point; - aspect Answer3a { - before(): execution(void Point.move(int, int)) { - Log.log("moving"); + before(): execution(public * *(..)) && within(figures.*) { + Log.log(thisJoinPoint.toString()); } } diff --git a/docs/teaching/exercises/answers/Answer3b.java b/docs/teaching/exercises/answers/Answer3b.java index 0328fe164..b88e45780 100644 --- a/docs/teaching/exercises/answers/Answer3b.java +++ b/docs/teaching/exercises/answers/Answer3b.java @@ -19,8 +19,11 @@ import figures.Group; import figures.FigureElement; aspect Answer3b { - before(): - execution(void Group.add(FigureElement)) && args(Point) { - Log.log("adding Point"); + before(Object o): + execution(public * *(..)) + && within(figures.*) && target(o) + && !withincode(public String toString(..)) // don't overflow! + { + Log.log(thisJoinPoint.toString() + " at " + o); } } diff --git a/docs/teaching/exercises/answers/Answer3c.java b/docs/teaching/exercises/answers/Answer3c.java index 576694e68..33483bc21 100644 --- a/docs/teaching/exercises/answers/Answer3c.java +++ b/docs/teaching/exercises/answers/Answer3c.java @@ -14,21 +14,11 @@ package answers; import support.Log; -import figures.Point; -import figures.Group; -import figures.FigureElement; +import figures.*; aspect Answer3c { - private Group Point.enclosingGroup = null; - - before(Point p, Group g): - execution(void add(FigureElement)) && args(p) && target(g) { - p.enclosingGroup = g; - } - - before(Point p): - call(void move(int, int)) && target(p) { - Log.log("moving as a part of " + p.enclosingGroup); + before(): + execution(void Group.add(FigureElement)) && args(Point) { + Log.log("adding Point"); } - } |