function loading for USSR
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace universal_science_solver.Physics {
|
||||
class BasicPhysics {
|
||||
public static void SpeedDistanceTime() {
|
||||
Console.WriteLine("Calculate distance, speed or time");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace universal_science_solver.Physics {
|
||||
class PhysicsControler {
|
||||
|
||||
public enum Topic : byte {
|
||||
USELECTED,
|
||||
BASICS,
|
||||
MECHANICS,
|
||||
WAVES
|
||||
}
|
||||
|
||||
public static IList<Mode> ModeList = new List<Mode>();
|
||||
|
||||
public static void Initializer() {
|
||||
ModeList.Add(new Mode("Speed distance time", Topic.BASICS, "Calculate distance, speed or time"));
|
||||
}
|
||||
|
||||
public static IList<Mode> ListModes() {
|
||||
foreach (Mode mode in ModeList) {
|
||||
Console.WriteLine(mode.Title);
|
||||
}
|
||||
return ModeList;
|
||||
}
|
||||
}
|
||||
|
||||
class Mode {
|
||||
public string Title;
|
||||
public PhysicsControler.Topic Topic;
|
||||
public string Desc;
|
||||
|
||||
public Mode(string title, PhysicsControler.Topic topic, string desc) {
|
||||
this.Title = title;
|
||||
this.Topic = topic;
|
||||
this.Desc = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace universal_science_solver.Physics {
|
||||
class PhysicsController {
|
||||
public enum Topic : byte {
|
||||
USELECTED,
|
||||
BASICS,
|
||||
MECHANICS,
|
||||
WAVES
|
||||
}
|
||||
|
||||
public static IList<Mode> ModeList = new List<Mode>();
|
||||
public static Dictionary<Topic, string> TopicDictionary = new Dictionary<Topic, string>();
|
||||
|
||||
public static void Initializer() {
|
||||
TopicDictionary.Add(Topic.USELECTED, "No topic selected");
|
||||
TopicDictionary.Add(Topic.BASICS, "Physics basics");
|
||||
TopicDictionary.Add(Topic.MECHANICS, "Mechanics");
|
||||
TopicDictionary.Add(Topic.WAVES, "Waves");
|
||||
|
||||
ModeList.Add(new Mode("Speed distance time", Topic.BASICS, "Calculate distance, speed or time", BasicPhysics.SpeedDistanceTime));
|
||||
}
|
||||
|
||||
public static void TakeControl() {
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Available physics modes:");
|
||||
listModes();
|
||||
selectMode();
|
||||
}
|
||||
|
||||
private static void selectMode() {
|
||||
Console.Write("> ");
|
||||
var key = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
|
||||
int index = 0;
|
||||
try {
|
||||
index = int.Parse(key.KeyChar.ToString()) - 1;
|
||||
Mode selected = ModeList[index];
|
||||
|
||||
Console.WriteLine("Mode [" + selected.Title + "] selected");
|
||||
selected.FunctionReference();
|
||||
Console.ReadKey();
|
||||
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine("You must select a number");
|
||||
selectMode();
|
||||
}
|
||||
}
|
||||
|
||||
private static IList<Mode> listModes() {
|
||||
for (int i = 0; i < ModeList.Count(); i++) {
|
||||
Console.Write("(" + (i + 1) + ") ");
|
||||
Console.Write(ModeList[i].Title);
|
||||
Console.Write(" in the topic [" + TopicDictionary[ModeList[i].Topic] + "]");
|
||||
}
|
||||
Console.WriteLine();
|
||||
return ModeList;
|
||||
}
|
||||
}
|
||||
|
||||
class Mode {
|
||||
public string Title;
|
||||
public PhysicsController.Topic Topic;
|
||||
public string Desc;
|
||||
public Action FunctionReference;
|
||||
|
||||
public Mode(string title, PhysicsController.Topic topic, string desc, Action functionReference) {
|
||||
this.Title = title;
|
||||
this.Topic = topic;
|
||||
this.Desc = desc;
|
||||
this.FunctionReference = functionReference;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace universal_science_solver {
|
||||
public Modes Mode = Modes.UNSELECTED;
|
||||
private bool isRunning = true;
|
||||
|
||||
public enum Modes : byte {
|
||||
public enum Modes : sbyte {
|
||||
UNSELECTED,
|
||||
PHYSICS,
|
||||
CHEMISTRY,
|
||||
@@ -15,20 +15,25 @@ namespace universal_science_solver {
|
||||
}
|
||||
|
||||
public UI() {
|
||||
Console.Clear();
|
||||
Console.WriteLine("Loading...");
|
||||
Thread.Sleep(400);
|
||||
PhysicsControler.Initializer();
|
||||
boot();
|
||||
eventLoop();
|
||||
PhysicsController.Initializer();
|
||||
while (isRunning) {
|
||||
boot();
|
||||
eventLoop();
|
||||
}
|
||||
}
|
||||
|
||||
private void boot() {
|
||||
Mode = Modes.UNSELECTED;
|
||||
Console.Clear();
|
||||
Console.WriteLine("The Universal Science Solver and Resolver");
|
||||
Console.WriteLine("Copyright 2018 Benjamin Kyd, Licensed under the MIT license");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Enter q at any point to return to the menu, Ctrl+C to exit the program at any time");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Physics (p), chemistry (c), mathematics (m)");
|
||||
}
|
||||
|
||||
private void eventLoop() {
|
||||
@@ -39,13 +44,13 @@ namespace universal_science_solver {
|
||||
}
|
||||
|
||||
if (Mode == Modes.PHYSICS) {
|
||||
|
||||
PhysicsController.TakeControl();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void selectMode() {
|
||||
Console.WriteLine("Physics (p), chemistry (c), mathematics (m)");
|
||||
Console.Write("> ");
|
||||
var key = Console.ReadKey();
|
||||
Console.WriteLine();
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Physics\PhysicsControler.cs" />
|
||||
<Compile Include="Physics\BasicPhysics.cs" />
|
||||
<Compile Include="Physics\PhysicsController.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="UI.cs" />
|
||||
|
||||
Reference in New Issue
Block a user