Calendar - for "REAL" programmers: Difference between revisions
Content added Content deleted
Line 819: | Line 819: | ||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA 3. |
ELENA 3.2 : |
||
<lang elena>import system'text. |
<lang elena>import system'text. |
||
import system'routines. |
import system'routines. |
||
import system'calendar. |
import system'calendar. |
||
import extensions. |
import extensions. |
||
import extensions'math. |
|||
import extensions'routines. |
import extensions'routines. |
||
Line 849: | Line 848: | ||
[ |
[ |
||
theRow set:0. |
theRow set:0. |
||
theDate := Date new year |
theDate := Date new year(theYear int) month(theMonth int) day:1. |
||
DayNames |
DayNames forEach(:aName) |
||
[ theLine |
[ theLine print(" ",aName) ] |
||
] |
] |
||
Line 860: | Line 859: | ||
if (theDate month == theMonth) |
if (theDate month == theMonth) |
||
[ |
[ |
||
theLine write:" " length |
theLine write:" " length((theDate dayOfWeek == 0)iif(7,theDate dayOfWeek) - 1). |
||
control do: |
control do: |
||
Line 873: | Line 872: | ||
int aLength := theLine length. |
int aLength := theLine length. |
||
if (aLength < 21) |
if (aLength < 21) |
||
[ theLine write:" " length |
[ theLine write:" " length(21 - aLength). ]. |
||
theRow append int:1. |
theRow append int:1. |
||
Line 884: | Line 883: | ||
readIndexTo vint:anIndex [ anIndex int := theRow ] |
readIndexTo vint:anIndex [ anIndex int := theRow ] |
||
writeIndex int:anIndex |
|||
[ |
[ |
||
if (anIndex <= theRow) |
if (anIndex <= theRow) |
||
Line 898: | Line 897: | ||
printTitleTo : anOutput |
printTitleTo : anOutput |
||
[ |
[ |
||
anOutput write |
anOutput write(MonthNames[theMonth - 1]) padding:21 with:$32. |
||
] |
] |
||
printTo : anOutput |
printTo : anOutput |
||
[ |
[ |
||
anOutput write |
anOutput write(theLine literal). |
||
] |
] |
||
} |
} |
||
Line 926: | Line 925: | ||
var aRowCount := 12 / theRowLength. |
var aRowCount := 12 / theRowLength. |
||
var Months := Array new length:aRowCount; |
var Months := Array new length:aRowCount; populate(:i) |
||
(Array new length:theRowLength; |
|||
populate(:j) |
|||
( CalendarMonthPrinter new year(theYear int) month(i * theRowLength + j + 1))). |
|||
Months |
Months forEach(:aRow) |
||
[ |
[ |
||
aRow |
aRow forEach(:aMonth) |
||
[ |
[ |
||
aMonth printTitleTo:anOutput. |
aMonth printTitleTo:anOutput. |
||
Line 941: | Line 941: | ||
anOutput writeLine. |
anOutput writeLine. |
||
ParallelEnumerator new:aRow; |
ParallelEnumerator new:aRow; forEach(:aLine) |
||
[ |
[ |
||
aLine |
aLine forEach(:aPrinter) |
||
[ |
[ |
||
aPrinter printTo:anOutput. |
aPrinter printTo:anOutput. |
||
Line 949: | Line 949: | ||
anOutput write:" " |
anOutput write:" " |
||
]. |
]. |
||
anOutput writeLine |
anOutput writeLine |
||
]. |
]. |
||
Line 957: | Line 958: | ||
program = |
program = |
||
[ |
[ |
||
var aCalender := Calendar new |
var aCalender := Calendar new(console write:"ENTER THE YEAR:"; readLineTo(Integer new)). |
||
aCalender printTo:console. |
aCalender printTo:console. |