Almost finish main
This commit is contained in:
parent
c9cce501bc
commit
4a47f58935
73
a1.py
73
a1.py
@ -204,12 +204,65 @@ def print_table(start_relative_elevation: float, step_size: float,
|
|||||||
|
|
||||||
print("#"*79)
|
print("#"*79)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
cmd, data = None, None
|
||||||
|
while True:
|
||||||
|
cmd = input("Please enter a command: ").lower()
|
||||||
|
|
||||||
|
# Help CMD
|
||||||
|
if cmd[0] == "h":
|
||||||
|
print(HELP_MESSAGE)
|
||||||
|
|
||||||
|
# Quit
|
||||||
|
if cmd[0] == "s":
|
||||||
|
while True:
|
||||||
|
cmd = input("Are you sure (y/n): ").lower()
|
||||||
|
if cmd in ['y', 'n']:
|
||||||
|
break
|
||||||
|
print("Please enter a valid reponse")
|
||||||
|
if cmd == 'y':
|
||||||
|
break
|
||||||
|
|
||||||
|
# Read Data
|
||||||
|
elif cmd[0] == "r":
|
||||||
|
directory = input("Please specify the directory: ")
|
||||||
|
filename = input("Please specify the filename: ")
|
||||||
|
data = load_data(directory, filename)
|
||||||
|
|
||||||
|
# Print Table
|
||||||
|
elif cmd[0] == "p":
|
||||||
|
if data is None:
|
||||||
|
print("Please load data before using this command")
|
||||||
|
|
||||||
|
cmd = cmd.split()
|
||||||
|
if len(cmd) != 4:
|
||||||
|
print("Please enter the correct number of arguments")
|
||||||
|
continue
|
||||||
|
|
||||||
|
print_table(*cmd[1:], *data)
|
||||||
|
|
||||||
|
# Make Graph
|
||||||
|
elif cmd[0] == "s":
|
||||||
|
if data is None:
|
||||||
|
print("Please load data before using this command")
|
||||||
|
|
||||||
|
print("Simulating water heights...")
|
||||||
|
heights = calc_heights_water_out(*data[0:5])
|
||||||
|
|
||||||
|
plot_water_height(heights, data[4])
|
||||||
|
|
||||||
|
# Catch All
|
||||||
|
else:
|
||||||
|
print("Please enter a valid command")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# See if I get what the task sheet wants
|
# See if I get what the task sheet wants
|
||||||
# [NOTE] It seems I am witing my own test suite :/ that wasn't the initention lol
|
# [NOTE] It seems I am witing my own test suite :/ that wasn't the initention lol
|
||||||
# Tests do equal what I get when i test it in the shell
|
# Tests do equal what I get when i test it in the shell
|
||||||
def sheet_tasks():
|
def sheet_tasks():
|
||||||
from debug_lib import NO_EVAL, TUPLE_EVAL
|
from debug_lib import NO_EVAL, TUPLE_EVAL
|
||||||
from debug_lib import compair_outputs
|
from debug_lib import compair_outputs, auto_input
|
||||||
|
|
||||||
# from a1_alex import calc_daily_profit
|
# from a1_alex import calc_daily_profit
|
||||||
|
|
||||||
@ -225,10 +278,22 @@ def sheet_tasks():
|
|||||||
)
|
)
|
||||||
|
|
||||||
compair_outputs(TASKS)
|
compair_outputs(TASKS)
|
||||||
|
|
||||||
|
print("\nTask 8")
|
||||||
|
print_table(280, 20, 6, 30, 20, 40000, 1, 30, 0.02, 0.005, 85)
|
||||||
|
|
||||||
|
|
||||||
|
print("\nTask 9")
|
||||||
|
global input
|
||||||
|
input = auto_input([
|
||||||
|
"h", "s", "q", "n",
|
||||||
|
"r", "test", "test_data.txt",
|
||||||
|
"p 280 20 6", "s",
|
||||||
|
"q", "y"
|
||||||
|
])
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#sheet_tasks()
|
sheet_tasks()
|
||||||
|
|
||||||
print_table(280, 20, 6, 30, 20, 40000, 1, 30, 0.02, 0.005, 85)
|
|
Loading…
x
Reference in New Issue
Block a user