-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
124 lines (101 loc) · 2.98 KB
/
Main.cpp
File metadata and controls
124 lines (101 loc) · 2.98 KB
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
#include <iostream>
#include "Student.h"
using namespace std;
const int SIZE = 15;
int main()
{
char program = 0, selection = 0;
do
{
system("cls");
Student students[] =
{
Student("Jack", 180.1),
Student("Byran", 175.6),
Student("Charles", 178.3),
Student("Lucas", 168.4),
Student("Merry", 163.5),
Student("Caven", 172.8),
Student("Lily", 165.7),
Student("Olivia", 166),
Student("Ivy", 170.2),
Student("Elvis", 181.2),
Student("Jane", 160.5),
Student("Henry", 170.9),
Student("James", 171.3),
Student("Zoe", 164.9),
Student("Gris", 168.5),
};
cout << "---------------------------------------";
cout << "!!!!!Welcome to Bitwise Brotherhood!!!!!";
cout << "------------------------------------" << endl;
cout << endl;
cout << "Please select a function\n1. Sorting\n2. Searching" << endl << ">> ";
cin >> selection;
cout << endl;
if (selection == '1')
{
int orderChoice;
cout << "This is the original list: \n";
students[SIZE - 1].printStudent(students, SIZE);
cout << "\nSelect sorting order:\n1. Ascending\n2. Descending\nEnter your choice (1 or 2): ";
cin >> orderChoice;
cout << endl;
if (cin.fail())
{
cin.clear();
cin.ignore();
}
while (orderChoice != 1 && orderChoice != 2)
{
cout << "Invalid order selection, please try again." << endl;
cout << "\nSelect sorting order:\n1. Ascending\n2. Descending\nEnter your choice (1 or 2): ";
cin >> orderChoice;
cout << endl;
if (cin.fail())
{
cin.clear();
cin.ignore();
}
}
students[SIZE - 1].sortByHeight(students, SIZE, orderChoice);
if (orderChoice == 1)
{
cout << "This list is sorted in ascending order: " << endl;
}
else if (orderChoice == 2)
{
cout << "This list is sorted in descending order: " << endl;
}
students[SIZE - 1].printStudent(students, SIZE);
cout << "\nThis is the seating chart:\n";
students[SIZE - 1].displaySeating(students, SIZE, "");
}
else if (selection == '2')
{
string nameToSearch;
bool found;
Student foundStudent;
cout << "This is the original list: \n";
students[SIZE - 1].printStudent(students, SIZE);
cout << "\nEnter the name of the student to search: ";
cin >> nameToSearch;
found = students[SIZE - 1].searchByName(students, SIZE, nameToSearch, foundStudent);
if (found)
{
cout << "\nStudent found: " << foundStudent.name << ", Height: " << foundStudent.height << " cm" << endl
<< "This student seat in the row " << foundStudent.foundRow + 1 << " column " << foundStudent.foundColumn + 1 << endl;
}
else
{
cout << "\nStudent " << nameToSearch << " not found." << endl;
}
}
else
{
cout << "Invalid selection, please try again.\n";
}
cout << "\nDo you want to restart the program? (0 to stop)" << endl << ">> ";
cin >> program;
} while (program != '0');
}