finishing touches

This commit is contained in:
Yadunand Prem 2022-09-19 20:30:36 +08:00
parent 05a6f3e572
commit caccc490fe
6 changed files with 11 additions and 11 deletions

View File

@ -12,5 +12,5 @@
*/
interface Applicable<T> {
<R> Applicable<R> apply(Immutator<Probably<R>, Probably<T>> immutator);
<R> Applicable<R> apply(Probably<Immutator<R, T>> probablyImmutator);
}

View File

@ -1,5 +1,5 @@
/**
* The Immutator interface that can transform
* The Immutator interface that can transform
* to type T2, an object of type T1.
*
* Contains a single abstract method invoke.
@ -10,6 +10,6 @@
* @author Yadunand Prem (10B)
*/
interface Immutator<R,P> {
interface Immutator<R, P> {
public R invoke(P param);
}

View File

@ -5,7 +5,7 @@
* CS2030S Lab 4
* AY22/23 Semester 1
*
* @author Put Your Name (Lab Group)
* @author Yadunand Prem (10B)
*/
class Improbable<T> implements Immutator<Probably<T>, T> {

View File

@ -8,7 +8,7 @@
* CS2030S Lab 4
* AY22/23 Semester 1
*
* @author Put Your Name (Lab Group)
* @author Yadunand Prem (10B)
*/
class IsModEq implements Immutator<Boolean, Integer> {

View File

@ -5,12 +5,12 @@
* CS2030S Lab 4
* AY22/23 Semester 1
*
* @author Put Your Name (Lab Group)
* @author Yadunand Prem (10B)
*/
class Print implements Action<Object> {
@Override
@Override
public void call(Object item) {
System.out.println(item);
}

View File

@ -124,11 +124,11 @@ class Probably<T> implements Actionable<T>, Immutatorable<T>, Applicable<T> {
}
@Override
public <R> Probably<R> apply(Immutator<Probably<R>, Probably<T>> immutator) {
if (this.value == null) {
return none();
public <R> Probably<R> apply(Probably<Immutator<R, T>> probablyImmutator) {
if (this.value != null && probablyImmutator.value != null) {
return just(probablyImmutator.value.invoke(this.value));
}
return immutator.invoke(this);
return none();
}
}