This repository has been archived by the owner on May 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
119 lines (110 loc) · 3.42 KB
/
Main.java
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
import java.sql.*;
/**
*
* The {@code Main} class is the entry point for the HangMan application. It
* initializes the database and invokes the {@code Word} and {@code GUI}
* constructors by creating instances of the respective classes.
*
* <p>
* The database driver used is PostgreSQL JDBC Driver (PgJDBC v42.2.18).
* ElephantSQL was the PostgreSQL service used. Database connections are routed
* to the instance HangMan created for Emmanuel Jojy (outmail*****@gmail.com) -
* Plan Tiny Turtle. Other details of the database is hidden for maintaining
* integrity of the database and data contained within it.
* </p>
*
* <p>
* WARNING: This project was created without keeping in mind about the privacy
* concerns. There is no sort of encryption provided for neither the username
* and password. Everything exist a raw text ({@code VARCHAR}). Emmanuel Jojy
* can view entire contents of the database if he requires
* </p>
*
* <p>
* Copyright (c) 2021. All rights reserved to Emmanuel Jojy. Use is subject to
* the above conditions.
* </p>
*
* <p>
* Hope it gives a feel of a classified and confidential document. I'm just
* joking and the entire project was created for fun. With lots of love @emmanu
* ;)
* </p>
*
* @author Emmanuel Jojy
*
*/
public class Main {
/**
* The current word being played in HangMan. The {@code Word} class initializes
* this field.
*/
static String word;
/**
* An instance of {@code HangMan} class. Initially set to {@code null} and is
* modified by the {@code start()} method.
*/
static HangMan hm;
/**
* The {@code Statement} object for performing queries to the database. The
* entire applications uses this instance for communication to the database.
*/
static Statement st;
/**
* Default constructor left as is, since there are no instance fields specific
* to the class. All fields are of type static.
*/
public Main() {
}
/**
* Self explanatory. Intended for call single time and origin of call the
* {@code Main} class.
*/
private void db() {
try {
/*
* Class.forName("org.sqlite.JDBC"); Connection c =
* DriverManager.getConnection("jdbc:sqlite:db.db");
*/
Class.forName("org.postgresql.Driver");
Connection c = DriverManager.getConnection("jdbc:postgresql://john.db.elephantsql.com:5432/deauwbtx",
"deauwbtx", "T-JrcXbHqBoOcEbbbdfC-5_JMbXJv7aI");
st = c.createStatement();
} catch (SQLException e) {
System.out.println("#DB Error - " + e);
System.exit(0);
} catch (ClassNotFoundException e) {
System.out.println("#postgresql Driver Error - " + e);
System.exit(0);
}
System.out.println("Main");
System.out.println(" L db - Complete");
}
/**
* Modifies the {@code word} and {@code hm} fields on invokation. This method is
* only and only called when an instance of {@code Game} class is to be created
* by the {@code game()} method in {@code GUI}.
*/
public static void start() {
word = Word.getWord().toUpperCase();
// Comment Line Below
//
// ------------------
hm = new HangMan();
}
/**
* The one and only intended entry point. Kickstarts the entire application. The
* only {@code main()} method in the entire application.
* <p>
* Invokes a private method {@code db()} for intializing the database and sets
* up the {@code GUI}.
* </p>
*
* @param args Not required. Optional
*/
public static void main(String[] args) {
Main obj = new Main();
obj.db();
new GUI();
}
}