Topics;
static Style style = Style.WithText;
static Sort sort = Sort.ByMostRecent;
// Actions: enabling condition, then action method
static bool SelectMessagesEnabled()
{
return (page == Page.Topics);
}
[Action]
static void SelectMessages()
{
page = Page.Messages;
}
static bool SelectTopicsEnabled()
{
return (page == Page.Messages);
}
[Action]
static void SelectTopics()
{
page = Page.Topics;
}
// to be continued ...
Figure 5.4. Web-based newsreader: model program (part 1).
66 Model Programs
static bool ShowTitlesEnabled()
{
return (page == Page.Topics && style == Style.WithText);
}
[Action]
static void ShowTitles()
{
style = Style.TitlesOnly;
}
static bool ShowTextEnabled()
{
return (page == Page.Topics && style == Style.TitlesOnly);
}
[Action]
static void ShowText()
{
style = Style.WithText;
}
static bool SortByFirstEnabled()
{
return (page == Page.Topics && style == Style.TitlesOnly
&& sort == Sort.ByMostRecent);
}
[Action]
static void SortByFirst()
{
sort = Sort.ByFirst;
}
static bool SortByMostRecentEnabled()
{
return (page == Page.Topics && style == Style.TitlesOnly
&& sort == Sort.ByFirst);
}
[Action]
static void SortByMostRecent()
{
sort = Sort.ByMostRecent;
}
}
}
Figure 5.5. Web-based newsreader: model program (part 2).
Systems with Finite Models 67
5.4.1 Program structure
A model program must include using statements to use the namespaces of the modeling
library NModel.
Pages:
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109