EX06 - Scenario2

Moderatoren: pmueller, SE - Design and Construction

Benutzeravatar
UdoWeber
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 156
Registriert: 8. Nov 2009 15:13

EX06 - Scenario2

Beitrag von UdoWeber »

I think @ViolatingValueFactory and the static method must be above/in class Stack not class Map[...}, right?

Code: Alles auswählen

public static XXX violatingValue() { return XXX; }
@ViolatingValueFactory(name="violatingValue") // has to annotate (it at all) "push"
public void push(V v) { ... }
class Map {...}

Benutzeravatar
UdoWeber
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 156
Registriert: 8. Nov 2009 15:13

Re: EX06 - Scenario2

Beitrag von UdoWeber »

So I didn't get the task at all :(

What I understand, we have some code like:

Code: Alles auswählen

		
Stack<Integer> stack = new Stack<Integer>();
stack.push(new Integer(5));
that worked with the allready given push method.

Then the developer adds a method push to the class Stack like this:

Code: Alles auswählen

public void push(Stack<V> s) {
    // TODO Implement
}
Now I need to find a value for "stack.push(new Integer(5));" that will no longer compile the method call, but did before adding the additional push, did I get this right?


Thanks for help, Udo

nknauber
Erstie
Erstie
Beiträge: 11
Registriert: 25. Apr 2018 16:48

Re: EX06 - Scenario2

Beitrag von nknauber »

+1

Could someone please clarify, what this scenario is about? :)

EDIT: Also: the annotation ViolatingValueFactory only has a parameter named 'value' and not 'name'. Furthermore, if I specify a method that runs into the mentioned error by calling push, the package cannot be compiled anymore, as this is a CompileTimeError. Should we still implement such a method and submit a "non-compilable" project?

Benutzeravatar
UdoWeber
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 156
Registriert: 8. Nov 2009 15:13

Re: EX06 - Scenario2

Beitrag von UdoWeber »

As far as I understand it, you just need to add the method.

Code: Alles auswählen

public static XXX violatingValue() { return XXX; }
And the annotation

Code: Alles auswählen

@ViolatingValueFactory
You should not implement the push method, just think about what happens if you do so.

Code: Alles auswählen

public void push(Stack<V> s) {
    // TODO Implement
}

pmueller
Moderator
Moderator
Beiträge: 87
Registriert: 25. Jan 2018 11:14

Re: EX06 - Scenario2

Beitrag von pmueller »

Hi,
UdoWeber hat geschrieben:
12. Jun 2018 16:53
You should not implement the push method, just think about what happens if you do so.
Correct.
nknauber hat geschrieben:
12. Jun 2018 14:44
EDIT: Also: the annotation ViolatingValueFactory only has a parameter named 'value' and not 'name'.
Yes, sorry about that, please use value instead of name.
UdoWeber hat geschrieben:
11. Jun 2018 15:09
I think @ViolatingValueFactory and the static method must be above/in class Stack not class Map[...}, right?
Yes.

As a hint: What can result from the fact that there are two methods with the same name that only differ in one (non-primitive) parameter type in the class Stack?

Best,
Patrick

Antworten

Zurück zu „Software Engineering - Design and Construction“