Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Gilles ARDOUREL
TD-685
Commits
a16e1395
Commit
a16e1395
authored
Feb 10, 2021
by
sunye
Browse files
Add partial correction of ex. 7
parent
c006308c
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/fr/unantes/l3/construction/exercice6/ReferenceToAction.java
View file @
a16e1395
...
...
@@ -31,15 +31,19 @@ public class ReferenceToAction {
public
void
unSet
()
{
if
(
action
.
isPresent
())
{
action
.
get
()
.
button
(
).
basicUnset
();
opposite
(
action
.
get
()).
basicUnset
();
this
.
basicUnset
();
}
}
private
ReferenceToButton
opposite
(
Action
action
)
{
return
action
.
button
();
}
public
void
set
(
Action
action
)
{
this
.
basicSet
(
action
);
action
.
button
(
).
basicSet
(
this
.
container
);
opposite
(
action
).
basicSet
(
this
.
container
);
}
public
Action
get
()
{
...
...
src/main/java/fr/unantes/l3/construction/exercice7/Action.java
0 → 100644
View file @
a16e1395
package
fr.unantes.l3.construction.exercice7
;
public
class
Action
{
}
src/main/java/fr/unantes/l3/construction/exercice7/Button.java
0 → 100644
View file @
a16e1395
package
fr.unantes.l3.construction.exercice7
;
public
class
Button
{
}
src/main/java/fr/unantes/l3/construction/exercice7/ReferenceToOne.java
0 → 100644
View file @
a16e1395
package
fr.unantes.l3.construction.exercice7
;
import
java.util.Optional
;
public
class
ReferenceToOne
<
C
,
T
>
{
private
final
C
container
;
private
Optional
<
T
>
target
=
Optional
.
empty
();
public
ReferenceToOne
(
C
container
)
{
this
.
container
=
container
;
}
public
boolean
isSet
()
{
return
target
.
isPresent
();
}
public
void
basicSet
(
T
newTarget
)
{
if
(
this
.
isSet
())
{
this
.
unSet
();
}
else
{
this
.
target
=
Optional
.
of
(
newTarget
);
}
}
public
void
basicUnset
()
{
if
(
target
.
isPresent
())
{
target
=
Optional
.
empty
();
}
}
public
void
unSet
()
{
if
(
target
.
isPresent
())
{
opposite
(
target
.
get
()).
basicUnset
();
this
.
basicUnset
();
}
}
private
ReferenceToOne
<
T
,
C
>
opposite
(
T
target
)
{
return
null
;
//return target.button();
}
public
void
set
(
T
newTarget
)
{
this
.
basicSet
(
newTarget
);
opposite
(
newTarget
).
basicSet
(
this
.
container
);
}
public
T
get
()
{
return
target
.
get
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment