Anonymous user
Calendar - for "REAL" programmers: Difference between revisions
Calendar - for "REAL" programmers (view source)
Revision as of 08:24, 27 February 2015
, 9 years ago→{{header|Elena}}
m ({{out}}) |
|||
Line 488:
=={{header|Elena}}==
<lang elena>#define system.
Line 512 ⟶ 510:
#field theRow.
#constructor new &
[
theMonth := aMonth.
theYear := aYear.
theLine := TextBuffer new.
theRow := Integer new &int:0.
]
#method
[
theRow << 0.
theDate := Date new &
control
[ theLine write:" " write:aName ].
]
#method
[
theLine clear.
(theDate
? [
theLine
control do:
[
theLine
theDate := theDate add &
]
&until:[(theDate
].
#var(type:int) aLength := theLine length.
(aLength < 21)
? [ theLine
theRow += 1.
^ theRow < 7.▼
]
#method
{
write &index:anIndex
▲ [
? [ self writeTitle. ].▼
#loop (anIndex > theRow) ?
[ self writeLine. ].
▲ ]
get = self.
}.
Line 565 ⟶ 570:
#method printTitleTo : anOutput
[
anOutput
]
Line 576 ⟶ 581:
#class Calendar
{
#field(type:int) theYear.
#field(type:int) theRowLength.
#constructor new : aYear
Line 587 ⟶ 592:
#method printTo:anOutput
[
anOutput
anOutput
anOutput::stringOp write:theYear &padding:(theRowLength * 25) &with:" ".
anOutput writeLine writeLine.
#var(type:int) aRowCount := 12 / theRowLength.
#var Months :=
(&index:i &index:j) [ CalendarMonthPrinter new &year:(theYear int) &month:((i * theRowLength + j + 1) int) ].
control
[
control
[
aMonth printTitleTo:anOutput.
Line 604 ⟶ 612:
anOutput writeLine.
control
[
control
[
aPrinter printTo:anOutput.
anOutput write:" ".
].
anOutput writeLine.
].
].
]
}
#symbol program =
[
#var aCalender := Calendar new:(consoleEx write:"
aCalender printTo:consoleEx.
|