consumer-example.sleela
lib/advantage/examples/novice/consumer-outcomes/consumer-example.sleela · 82 line(s) · sleela
<< lib/advantage/examples/novice/consumer-outcomes/consumer-example.sleela
SLeeLa Standard Library Definition.
Definition: A professional example -- the CONSUMER -- uses the simple user's
model of the Sequitur onion to advantage a household budget. >>
#sleela 3.0
material;
artifact;
pure;
gasoline;
<< A consumer wants the outcome, not the controls. The user's model of the
onion (advantage/SLAdvantageUserModel) gives three plain dials over the
layered process: grow (additions), shrink (a cost, negative), and rethink
(quantitative + regrouping). On a base of 50 with grow 30, shrink -12, and
rethink(10, 2), the net advantage is 30 - 12 + 10 + 2 = 30, so the running
value becomes 80. Names SLAdvantageUserModel, resolved from lib/advantage/. >>
class ConsumerExample {
< ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- >
<< Baseline identity record for a worker-class example. >>
String metaVersion = "1.0.0";
int metaId = 10574;
String metaAuthor = "Kiro Agent";
String metaDate = "2026-11-08";
String metaCopyright = "SLeeLa project";
String metaTrademark = "none";
String metaCorporation = "none";
< metaOrigin: National | <nation> | International | Galactic >
String metaOrigin = "International";
String metaBirthDate = "2026-11-08";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 8;
< metaNationalSchedule: a real, citable instrument or "none" >
String metaNationalSchedule = "none";
String getMetaVersion() { return metaVersion; }
void setMetaVersion(String v) { metaVersion = v; }
int getMetaId() { return metaId; }
void setMetaId(int v) { metaId = v; }
String getAuthor() { return metaAuthor; }
void setAuthor(String v) { metaAuthor = v; }
String getDate() { return metaDate; }
void setDate(String v) { metaDate = v; }
String getCopyright() { return metaCopyright; }
void setCopyright(String v) { metaCopyright = v; }
String getTrademark() { return metaTrademark; }
void setTrademark(String v) { metaTrademark = v; }
String getCorporation() { return metaCorporation; }
void setCorporation(String v) { metaCorporation = v; }
String getOrigin() { return metaOrigin; }
void setOrigin(String v) { metaOrigin = v; }
String getBirthDate() { return metaBirthDate; }
void setBirthDate(String v) { metaBirthDate = v; }
int getScienceRating() { return metaScienceRating; }
void setScienceRating(int v) { metaScienceRating = v; }
String getNationalSchedule() { return metaNationalSchedule; }
void setNationalSchedule(String v) { metaNationalSchedule = v; }
void main() {
print("== professional: the Consumer ==");
SLAdvantageUserModel user = new SLAdvantageUserModel();
user.start("savings", "household-budget", 50);
user.ownedBy("the household");
user.grow(30);
user.shrink(0 - 12);
user.rethink(10, 2);
int adv = user.advantage();
int value = user.currentValue();
print(" base value = 50");
print(" net advantage = " + adv);
print(" value after process = " + value);
print("");
print("== validation ==");
boolean okAdv = (adv == 30);
boolean okValue = (value == 80);
print(" net advantage == 30 ? " + okAdv);
print(" value == 80 ? " + okValue);
if (okAdv) { if (okValue) {
print("ALL CHECKS PASSED");
} }
}
}