-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGathering.java
More file actions
143 lines (121 loc) · 4.7 KB
/
Gathering.java
File metadata and controls
143 lines (121 loc) · 4.7 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
import javax.xml.stream.Location;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Scanner;
public class Gathering {
public String hostName, eventName, eventType, description, allAges, volunteersWanted, location;
public int date;
public int entryFee;
Scanner sc = new Scanner(System.in);
DBConnect connect = new DBConnect();
public static Connection conn = null;
Statement st = null;
static final String URL = "jdbc:mysql://192.168.72.21:3306/thehub";
//User log in for DB
static final String USER = "TheHub";
static final String PASS = "$TheHub2023$";
public Gathering() {
System.out.print("When is the event? Enter in DDMMYYYY Format..");
try {
this.date = Integer.parseInt(sc.nextLine());
} catch (NumberFormatException e) {
e.printStackTrace();
}
System.out.print("Enter your Name: ");
this.hostName = sc.nextLine().trim().toLowerCase();
System.out.print("What do you want to call this event?");
this.eventName = sc.nextLine().trim().toLowerCase();
System.out.print("What type of event is this?");
this.eventType = sc.nextLine().trim().toLowerCase();
System.out.print("Where is the event?");
this.location = sc.nextLine().trim().toLowerCase();
System.out.print("Enter a brief description of your event:");
this.description = sc.nextLine().trim().toLowerCase();
System.out.print("What is the entry fee? (Enter dollar amount only)");
try {
this.entryFee = Integer.parseInt(sc.nextLine());
} catch (NumberFormatException e) {
e.printStackTrace();
}
System.out.print("Is this event all ages?");
this.allAges = sc.nextLine().trim().toLowerCase();
System.out.print("Do you want volunteers?");
this.volunteersWanted = sc.nextLine().trim().toLowerCase();
writeEvent();
}
//TODO figure out how to get these to work or just remove them.
public void readDate() throws Exception{
String dateFormat = "MM/DD/YYYY";
Scanner scanner = new Scanner(System.in);
//setDate((Date) new SimpleDateFormat(dateFormat).parse(scanner.nextLine()));
}
public void setDate(int date){
System.out.print("When is the event?");
try {
this.date = Integer.parseInt(sc.nextLine());
} catch (NumberFormatException e) {
e.printStackTrace();
}
}
public void writeEvent() {
try {
DBConnect.getInstance();
conn = DriverManager.getConnection(URL, USER, PASS);
st = conn.createStatement();
System.out.println("Writing event to database...");
String sql = "INSERT INTO events (date, host, event_name, location, event_type, description, all_ages, entry_fee, volunteers) " +
"VALUES ('" + this.date + "', '" + this.hostName + "', '" + this.eventName + "', '" + this.location + "', '" + this.eventType + "', '" + this.description + "', '" + this.allAges + "', '" + this.entryFee + "', '" + this.volunteersWanted + "');";
st.executeUpdate(sql);
System.out.println("Record inserted successfully");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
Location gatheringLocation = new Location() {
@Override
public int getLineNumber() {
return 0;
}
@Override
public int getColumnNumber() {
return 0;
}
@Override
public int getCharacterOffset() {
return 0;
}
@Override
public String getPublicId() {
return null;
}
@Override
public String getSystemId() {
return null;
}
};
}
public class mockevent {
private Event event;
public mockevent() {
LocalDateTime dateTime = LocalDateTime.of(2023, 4, 22, 21, 0);
this.event = new Event("KikiPlanet.Productions", "POP SICK DANCE PARTY", "Party", "Louies Sports Bar, Blue Lake CA",
"POP SICK DANCE PARTY by KikiPlanet.Productions", 25.0, false, false, dateTime);
writeEvent();
}
public void writeEvent() {
String eventInfo = this.event.generateEventInfo();
System.out.println("Creating event: " + eventInfo);
// code to add event to calendar and store in database
}
}