-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnewCollectionEvent.java
More file actions
124 lines (76 loc) · 4.05 KB
/
Copy pathnewCollectionEvent.java
File metadata and controls
124 lines (76 loc) · 4.05 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
import java.util.Scanner;
import javax.sound.sampled.BooleanControl.Type;
import java.io.*;
import java.util.*;
public class newCollectionEvent {
public static void newCollectionEvent() {
try {
//get input from user
Scanner scn = new Scanner(System.in);
System.out.println("Enter Collection Information: ");
System.out.println("Enter Collection ID: ");
String collectionID = scn.nextLine();
System.out.println("Enter Title: ");
String title = scn.nextLine();
System.out.println("Enter Publisher: ");
String publisher = scn.nextLine();
System.out.println("Enter Genre: ");
String genre = scn.nextLine();
//type
String type = "";
while (true) {
System.out.println("Enter Type: DVDS, Books, Journals, Newspapers: ");
type = scn.nextLine().toLowerCase();
if (type.equals("dvds") || type.equals("books") || type.equals("journals")
|| type.equals("newspapers")) {
break;
} else {
System.out.println("Invalid collection type. Please enter DVDS, Books, Journals, or Newspaper.");
}
}
//switch based on type of collection and make new collection based on switch case
switch (type) {
case "dvds":
System.out.print("Enter ISBN: ");
String ISBN = scn.nextLine();
DVDs mem = new DVDs(collectionID, title, publisher, genre, ISBN, type);
System.out.print("Creating a new member...");
SaveToFile.save(mem.toString(), "Collectiondatabase.txt");
break;
case "books":
System.out.print("Enter ISBN: ");
ISBN = scn.nextLine();
System.out.print("Enter Author: ");
String author = scn.nextLine();
Books mem1 = new Books(collectionID, title, publisher, genre, ISBN, author, type);
System.out.print("Creating a new member...");
SaveToFile.save(mem1.toString(), "Collectiondatabase.txt");
//System.out.print(mem1.toString());
break;
case "journals":
System.out.print("Enter ISSN: ");
String ISSN = scn.nextLine();
System.out.print("Enter Author: ");
author = scn.nextLine();
Journals mem2 = new Journals(collectionID, title, publisher, genre, type, ISSN, author);
System.out.print("Creating a new member...");
SaveToFile.save(mem2.toString(), "Collectiondatabase.txt");
break;
case "newspapers":
System.out.print("Enter ISSN: ");
ISSN = scn.nextLine();
Newspapers mem3 = new Newspapers(collectionID, title, publisher, genre, type, ISSN);
System.out.print("Creating a new member...");
SaveToFile.save(mem3.toString(), "Collectiondatabase.txt");
break;
default:
System.out.println("Invalid collection type. Please enter DVDS, Books, Journals, or Newspaper.");
return;
}
//catch error and output
} catch (Exception e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
}
}