Compare commits

..

No commits in common. "example_8" and "master" have entirely different histories.

5 changed files with 0 additions and 81 deletions

View File

@ -1,15 +0,0 @@
.dub
docs.json
__dummy.html
docs/
/example_8
example_8.so
example_8.dylib
example_8.dll
example_8.a
example_8.lib
example_8-test-*
*.exe
*.o
*.obj
*.lst

View File

@ -1,9 +0,0 @@
{
"authors": [
"Alexander"
],
"description": "Интерфейсы и классы",
"license": "proprietary",
"name": "example_8",
"targetPath": "bin"
}

View File

@ -1,26 +0,0 @@
import std.stdio : writeln, stdin;
import std.exception : enforce;
import min_, stat_;
void main(string[] args)
{
Stat[] stats;
foreach (arg; args[1 .. $])
{
auto newStat = cast(Stat) Object.factory("min_." ~ arg);
enforce(newStat, "Invalid statistics function: " ~ arg);
stats ~= newStat;
}
for (double x; stdin.readf(" %s ", &x) == 1;)
{
foreach (s; stats)
{
s.accumulate(x);
}
}
foreach (s; stats)
{
s.postprocess();
writeln(s.result());
}
}

View File

@ -1,23 +0,0 @@
module min_;
import stat_;
class Min : Stat
{
private double min = double.max;
void accumulate(double x)
{
if (x < min)
{
min = x;
}
}
void postprocess() {}
double result()
{
return min;
}
}

View File

@ -1,8 +0,0 @@
module stat_;
interface Stat
{
void accumulate(double x);
void postprocess();
double result();
}