mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-08-22 18:25:33 +00:00
docs: update memento
This commit is contained in:
@@ -67,7 +67,7 @@ public class App {
|
||||
states.add(star.getMemento());
|
||||
star.timePasses();
|
||||
LOGGER.info(star.toString());
|
||||
while (states.size() > 0) {
|
||||
while (!states.isEmpty()) {
|
||||
star.setMemento(states.pop());
|
||||
LOGGER.info(star.toString());
|
||||
}
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
*/
|
||||
package com.iluwatar.memento;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Star uses "mementos" to store and restore state.
|
||||
*/
|
||||
@@ -85,34 +88,12 @@ public class Star {
|
||||
/**
|
||||
* StarMemento implementation.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
private static class StarMementoInternal implements StarMemento {
|
||||
|
||||
private StarType type;
|
||||
private int ageYears;
|
||||
private int massTons;
|
||||
|
||||
public StarType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(StarType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getAgeYears() {
|
||||
return ageYears;
|
||||
}
|
||||
|
||||
public void setAgeYears(int ageYears) {
|
||||
this.ageYears = ageYears;
|
||||
}
|
||||
|
||||
public int getMassTons() {
|
||||
return massTons;
|
||||
}
|
||||
|
||||
public void setMassTons(int massTons) {
|
||||
this.massTons = massTons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user