-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathV1.cpp
More file actions
165 lines (161 loc) · 3.26 KB
/
Copy pathV1.cpp
File metadata and controls
165 lines (161 loc) · 3.26 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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
const int maxnum = 50;
class Card
{
public:
string question;
string answer;
Card()
{
question = " ";
answer = " ";
}
Card(string q, string a)
{
question = q;
answer = a;
}
};
class Feedback
{
private:
public:
int marks;
Feedback()
{
marks = 0;
}
Feedback(int m)
{
marks = m;
}
};
class CardsManager
{
public:
Card cards[maxnum];
Feedback feedbacks[maxnum];
int num;
CardsManager()
{
num = 0;
}
void getNewCard(string ques, string ans)
{
if(num<maxnum)
{
cards[num] = Card(ques, ans);
num++;
cout << "\nCard is added successfully!" << endl;
}
else
{
cout << "Cannot add more cards. Maximum capacity reached." << endl;
}
}
void displayCards()
{
int point = 0;
if (num == 0)
{
cout << "No cards to display." << endl;
return;
}
else
{
cout << "\nTotal Cards = " << num << endl;
cout << endl;
for(int i=0; i<num; i++)
{
cout << "Question " << i+1 << ": " << cards[i].question << endl;
cout << "Answer " << i+1 << ": " << cards[i].answer << endl;
cout << "\nHow well did you know this? (0: Not well, 1: Normal, 2: Perfectly)" << endl;
cin >> point;
while(point < 0 || point >2)
{
cout << "Error. Please try again." << endl;
cin >> point;
if(point == 0 || point == 1 || point == 2 )
break;
}
feedbacks[i] = Feedback(point);
cout << endl;
}
}
}
};
class Process
{
private:
CardsManager cm;
string q;
string a;
public:
void addQuestion()
{
cout << "Enter Question: ";
cin >> q;
}
void addAnswer()
{
cout << "Enter Answer: ";
cin >> a;
}
void addCard()
{
addQuestion();
addAnswer();
cm.getNewCard(q, a);
}
void showCard()
{
cout << "Displaying flashcards..." << endl;
cm.displayCards();
}
};
class Menu
{
int choice;
Process p;
public:
Menu()
{
choice = 0;
}
void showMenu()
{
while(choice !=3)
{
cout << "\n===== Flash Card =====" << endl;
cout << "1. Add new card" << endl;
cout << "2. Display card" << endl;
cout << "3. Exit" << endl;
cout << "\nEnter choice: ";
cin >> choice;
system("CLS");
switch(choice)
{
case 1:
p.addCard();
break;
case 2:
p.showCard();
break;
case 3:
cout << "Exiting program." << endl;
break;
default:
cout << "Invalid choice! Please try again." << endl;
}
}
}
};
int main()
{
cout << "Hello\n";
Menu m1;
m1.showMenu();
}