static public void Main(System.String[] args) { IDatabase db = DatabaseFactory.CreateDatabase(); Rc4File dbFile = new Rc4File("guess.db", "GUESS"); db.Open(dbFile, 4 * 1024 * 1024); Guess root = (Guess)db.Root; while (askQuestion("Think of an animal. Ready (y/n) ? ")) { if (root == null) { root = whoIsIt(null); db.Root = root; } else { root.dialog(); } db.Commit(); } System.Console.WriteLine("End of the game"); db.Close(); }
internal Guess dialog() { if (askQuestion("May be, " + question + " (y/n) ? ")) { if (yes == null) { System.Console.WriteLine("It was very simple question for me..."); } else { Guess clarify = yes.dialog(); if (clarify != null) { yes = clarify; Store(); } } } else { if (no == null) { if (yes == null) { return(whoIsIt(this)); } else { no = whoIsIt(null); Store(); } } else { Guess clarify = no.dialog(); if (clarify != null) { no = clarify; Store(); } } } return(null); }
static public void Main(string[] args) { Storage db = StorageFactory.Instance.CreateStorage(); bool multiclient = args.Length > 0 && args[0].StartsWith("multi"); if (multiclient) { db.SetProperty("perst.multiclient.support", true); } db.Open("guess.dbs", 4 * 1024 * 1024, "GUESS"); while (askQuestion("Think of an animal. Ready (y/n) ? ")) { if (multiclient) { db.BeginThreadTransaction(TransactionMode.ReadWrite); } Guess root = (Guess)db.Root; if (root == null) { root = whoIsIt(null); db.Root = root; } else { root.dialog(); } if (multiclient) { db.EndThreadTransaction(); } else { db.Commit(); } } Console.WriteLine("End of the game"); db.Close(); }
static public void Main(System.String[] args) { Storage db = StorageFactory.Instance.CreateStorage(); db.Open("guess.dbs", 4 * 1024 * 1024, "GUESS"); Guess root = (Guess)db.Root; while (askQuestion("Think of an animal. Ready (y/n) ? ")) { if (root == null) { root = whoIsIt(null); db.Root = root; } else { root.dialog(); } db.Commit(); } System.Console.WriteLine("End of the game"); db.Close(); }