using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
namespace vyhodnoceni
{
public static class Program
{
public static void Main(string[] args)
{
if (args.Length < 2)
{
Console.WriteLine("Parametry jsou dve jmena souboru oddelena mezerou: sit vstupni-data");
}
else
{
string netFile = args[0];
string inputFile = args[1];
try
{
var net = Network.GetNetwork(netFile);
net.ProcessFile(inputFile);
}
catch (Exception exception)
{
Console.WriteLine("Program skoncil chybou: {0}", exception.Message);
}
}
}
private static void PerformTests()
{
// jednoducha funkce k otestovani vsech dodanych siti
string[] files = { "nevnorene1", "nevnorene2", "nevnorene3", "nevnorene4", "nevnorene5", "nevnorene6", "nevnorene7", "nevnorene8", "nevnorene9", "nevnoreneA", "vnorene1", "vnorene2", "vnorene3", "vnorene4", "vnorene5", "vnorene6", "vnorene7" };
foreach (var netFile in files)
{
string inputFile = netFile + ".in";
var net = Network.GetNetwork(netFile);
net.Testing = true;
net.ProcessFile(inputFile);
string myResults = net.OutputData;
string theirResults = new StreamReader(netFile + ".out").ReadToEnd();
Console.WriteLine("{0}: {1}", netFile, (myResults == theirResults) ? "OK" : "Failed");
}
Console.ReadKey();
}
}
// vstup, vystup nebo hradlo
public abstract class Node
{
protected bool? value = null;
public virtual bool HasValue()
{
return value != null;
}
public virtual bool GetValue()
{
return this.value.Value;
}
public void Reset()
{
value = null;
}
}
// vstup nebo vystup
public class ConnectionPoint : Node
{
protected string id;
protected void init(string id)
{
this.id = id;
}
}
public class Input : ConnectionPoint
{
protected Output output = null;
public Input(string id)
{
init(id);
}
// nastavi prislusny vystup, ze ktereho se ziskaji data
public void SetOutput(Output output)
{
this.output = output;
}
public override bool HasValue()
{
return this.output.HasValue();
}
public override bool GetValue()
{
return this.output.GetValue();
}
public string GetId()
{
return this.id;
}
}
public class Output : ConnectionPoint
{
public Output(string id)
{
init(id);
}
public void SetValue(bool value)
{
this.value = value;
}
}
public abstract class Gate : Node
{
protected List inputs = new List { };
protected List