-
Notifications
You must be signed in to change notification settings - Fork 0
/
CBU_Console.h
65 lines (56 loc) · 2.1 KB
/
CBU_Console.h
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
//
// Created by Frank Yang on 7/16/24.
//
// Copyright (c) 2024 Frank Yang
// All rights reserved.
//
// This code is proprietary and confidential.
// Unauthorized copying of this file, via any medium is strictly prohibited.
#ifndef CBU_CONSOLE_H
#define CBU_CONSOLE_H
#include <iostream>
#include "CBU_Balancer.h"
class CBU_Console {
public:
CBU_Console() { std::cout << CBU_Console::version() << CBU_Balancer::version() << std::endl << CBU_Console::guide_message() << std::endl; }
static std::string version();
static std::string guide_message();
void boot();
};
inline std::string CBU_Console::version() {
std::string welcome_message = "";
welcome_message += "Welcome to ChemicalBalancingUtilityNew Console v1.0.0!\n";
welcome_message += "Programmed by Frank Yang in Jul, 2024 \n";
return welcome_message;
}
inline std::string CBU_Console::guide_message() {
std::string guide_message = "";
guide_message += "Use quit() to quit the console.\n";
guide_message += "Use multiple_results(off)` to disable multiple results, use multiple_results(on) to allow it. Multiple results is enabled by default.\n" ;
guide_message += "Directly type your chemical equation to call the built-in ChemicalBalancingUtility to balance.\n";
return guide_message;
}
void CBU_Console::boot() {
std::string command;
CBU_Balancer balancer = CBU_Balancer();
balancer.set_log_status(false);
while (std::getline(std::cin, command)) {
if (command == "quit()") {
break;
}
else if (command == "multiple_results(on)") {
balancer.set_multiple_results(true);
std::cout << "Multiple results is allowed." << std::endl;
}
else if (command == "multiple_results(off)") {
balancer.set_multiple_results(false);
std::cout << "Multiple results is disabled. The balancing result my be not correct!" << std::endl;
}
else {
balancer.balance(command);
std::cout << balancer.get_result() << std::endl;
balancer.clear_data();
}
}
}
#endif // CBU_CONSOLE_H