-
Notifications
You must be signed in to change notification settings - Fork 0
/
View.cc
86 lines (57 loc) · 1.59 KB
/
View.cc
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
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
#include "View.h"
//View ctor
View::View(){
}
//View dtor;
View::~View(){
}
//Displays the main menu and reads in the user's selection
void View::mainMenu(int& selectionRef){
int numOptions = 1;
selectionRef = -1;
cout << endl;
cout << "(1) Add book" << endl;
cout << "(0) Exit" << endl;
cin >> selectionRef;
while(selectionRef < 0 || selectionRef > numOptions){
cout << "Enter your selection: ";
cin >> selectionRef;
}
}
//Reads all info from the user about one book
//OUTPUT parameters used in readBookInfo()
void View::readBookInfo(int& idRef, string& callNumberRef, string& titleRef, string& authorRef, int& yearRef){
cout << "id: ";
cin >> idRef;
cout << "title: ";
cin.ignore();
getline(cin, titleRef);
cout << "author: ";
getline(cin, authorRef);
cout << "year: ";
cin >> yearRef;
cout << "call number: ";
cin.ignore();
getline(cin, callNumberRef);
}
//Prints out the library, takes the library as a parameter, uses delegation to
//ask the Library class to print to the screen
void View::print(Library& libRef){
libRef.print();
}
void View::readBookType(int& fictNonFictRef){
int numOptions = 1;
fictNonFictRef = -1;
cout << endl;
cout << "(1) Non Fiction" << endl;
cout << "(0) Fiction" << endl;
cin >> fictNonFictRef;
while(fictNonFictRef < 0 || fictNonFictRef > numOptions){
cout << "Enter your selection: ";
cin >> fictNonFictRef;
}
}