-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cs
149 lines (140 loc) · 4.3 KB
/
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* main.cs
*
* Copyright 2021 Devin M. O'Brien <demo@BattleForge>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*/
using System;
public class SimpleStock
{
public static void Main()
{
bool exit = false;
SQLTranslator sql = new SQLTranslator();
StockList primary = sql.load();
string input;
sql.setup();
Console.WriteLine("Simple Stock\n==========");
while(!exit){
input = Console.ReadLine();
if(input =="add"){
Console.WriteLine("Enter Name:");
string name = Console.ReadLine();
Console.WriteLine("Enter Ticker:");
string token = Console.ReadLine();
Stock temp = new Stock(name, token);
primary.add_stock(temp);
input = "";
}
if(input == "update"){
Console.WriteLine("Stocks");
int counter = 0;
foreach(Stock stock in primary.stock){
Console.WriteLine(++counter + "). " + stock.name + "\n");
}
int sel = Int16.Parse(Console.ReadLine());
Stock current = primary.stock[sel-1];
Console.WriteLine(current.ToString());
Console.WriteLine("Update:\n1). Name\n2). Ticker\n3). Price");
sel = Int16.Parse(Console.ReadLine());
if(sel == 1){
Console.WriteLine("Enter Name");
current.name = Console.ReadLine();
}else{
if(sel == 2){
Console.WriteLine("Enter Ticker:");
current.token = Console.ReadLine();
}else{
Date temp = new Date();
Console.WriteLine("Enter Price:");
temp.price = float.Parse(Console.ReadLine());
current.date.Add(temp);
}
}
sql.save(primary);
input = "";
}
if(input=="edit"){
int counter = 0;
foreach(Stock stock in primary.stock){
Console.WriteLine(++counter +"). "+ stock.name);
}
int sel = Int16.Parse(Console.ReadLine());
Stock active = primary.stock[--sel];
counter = 0;
foreach(Date date in active.date){
Console.WriteLine(++counter + "). " + date.ToString());
}
sel = Int16.Parse(Console.ReadLine());
Date dte = active.date[--sel];
Console.WriteLine("1). Price: " + dte.price +"\n2). Date: " + dte.date);
sel = Int16.Parse(Console.ReadLine());
if(sel == 1){
Console.WriteLine("Enter New Price");
dte.price = float.Parse(Console.ReadLine());
}else{
Console.WriteLine("Enter New Date: (OLD) " + dte.date.ToString());
dte.date = DateTime.Parse(Console.ReadLine());
}
sql.save(primary);
}
// Print Active List
if(input == "print"){
Console.WriteLine(primary.ToString());
}
// Print Active List Name
if(input == "active"){
Console.WriteLine(primary.name);
}
if(input == "remove"){
int counter = 0;
foreach(Stock stock in primary.stock){
Console.WriteLine(++counter + "). " + stock.name +"\n");
}
int sel = Int16.Parse(Console.ReadLine());
primary.remove_stock(--sel);
input = "";
sql.save(primary);
}
if(input == "clear"){
Console.Clear();
}
if(input == "switch"){
Console.WriteLine("Enter List Name:");
string newList = Console.ReadLine();
if(newList != "" && newList != "prog"){
sql.save(primary);
sql.activeList = newList;
primary = sql.load();
}
}
// Creates New List
if(input == "create"){
Console.WriteLine("Enter Name:");
input = Console.ReadLine();
if(input != "prog" && input !="")
sql.createList(input);
}
// Exits
if(input == "exit"){
exit = true;
}
}
}
}