diff --git a/html-java-script/week13/APPS Lab Submission Example.docx b/html-java-script/week13/APPS Lab Submission Example.docx
new file mode 100644
index 0000000..2169f76
Binary files /dev/null and b/html-java-script/week13/APPS Lab Submission Example.docx differ
diff --git a/html-java-script/week13/discussion.org b/html-java-script/week13/discussion.org
new file mode 100644
index 0000000..5dc297a
--- /dev/null
+++ b/html-java-script/week13/discussion.org
@@ -0,0 +1,37 @@
+* 3 new
+** 1
+Despite using the same technologies, mobile websites tend to differ from desktop websites.
+
+The designers need to consider things such as, screen size, processing power available, and data.
+
+While I've seen plenty of that in regards to screen size, I have seen plenty of data and power waste when browsing mobile sites. The old mobile sites used to be super basic and didn't use much, but lately, I still see things like video pop ups autoloading and following me around the screen.
+
+** 2
+Web browsers send information to servers that identify itself so that the web pages can display information more appropriate to the device or specific web browser.
+** 3
+Subresource Integrity. I seem to remember reading about the web browsers only trusting JavaScript that came from the same domain. This kinda reminds me of a horror of troubles I ran into when I had to be on Windows (VB). Mark of the web. Hell of an error message to spit at someone when you're just trying to do class work. Anyway, I'm thinking that this subresource integrity concept is a much better version of that.
+
+If I understand it correctly, subresource integrity allows us to pull JavaScript from other domains that allow it to be treated as if it's from our own domain for security purposes.
+
+* 2 Interesting
+** 1
+Didn't realize that jQuery has been around since 2006. Of course, I was just a stupid teenager when it came out (Wait, did I just date myself? Am I old enough now to think about that?), and probably didn't even realize that JavaScript was much of a thing yet. Then again, it probably wasn't. Everyone finally was done (well...) with java applets and we were charging right in with a steaming pile of flash.
+** 2
+Instead of:
+$(document).ready( () => {});
+
+We can shorthand it as:
+$(() => {});
+
+I'm not sure I care for that. I enjoy concise, and it's certainly nice for minifiying, but readability is gone. Which, probably doesn't matter much, but still. Though, I do like how I feel like I'm using a half-baked lisp with the shorthand method.
+
+
+* 1 unclear
+I suppose what's least clear is the responsive/reactive/adaptave ideas. Aren't they mostly just progressions of the same concept? We started out responding to screen sizes with media queries that caused jerkiness while resizing windows and what not, but then we progressed to scaling more smoothly and such. Why do we need all of these things still?
+
+
+
+NOTE: 12:33 may hold all answers for assignment
+SRI checking at 1625
+
+At 45 mins
diff --git a/html-java-script/week13/expand_collapse/expand_collapse.zip b/html-java-script/week13/expand_collapse/expand_collapse.zip
new file mode 100644
index 0000000..8661deb
Binary files /dev/null and b/html-java-script/week13/expand_collapse/expand_collapse.zip differ
diff --git a/html-java-script/week13/expand_collapse/index.html b/html-java-script/week13/expand_collapse/index.html
new file mode 100644
index 0000000..0fcbbba
--- /dev/null
+++ b/html-java-script/week13/expand_collapse/index.html
@@ -0,0 +1,70 @@
+
+
+
+
+
+ Expand/Collapse
+
+
+
+
+
+
Murach's HTML5 and CSS3 (4th Edition)
+
Book description
+
+
Murach's HTML5 and CSS3 provides all HTML and CSS a professional needs, and it
+ adds coverage of Flexible Box and Grid Layout, two new CSS3 ways to implement page
+ layouts. So whether you're a web designer, a JavaScript programmer, a server-side
+ programmer, or a rookie, this book delivers all the HTML and CSS skills that you
+ need on the job. It begins with an 8-chapter hands-on course that teaches you HTML
+ and CSS from scratch, including the latest HTML5 and CSS3 features.
+
+
+
After that, you'll learn how to use Flexible Box and Grid Layout, and how to work
+ with forms and data validation. Then you'll learn how to enhance a site with video
+ clips, CSS3 transitions, transforms, and animations. You'll learn how to design and
+ deploy a website, as well as other professional skills like how to use JavaScript and
+ jQuery and how to use development tools like Bootstrap, SASS, and Emmet. And after
+ you've learned all the skills that you need, this book becomes the best on-the-job
+ reference you've ever used.
Anne Boehm has over 30 years of experience as an enterprise programmer. She got
+ started with Visual Basic in the days of VB5 and has been programming on .NET since
+ its inception. She added C# to her programming repertoire in the mid-2000s, and she's
+ authored or co-authored our books on Visual Basic, C#, ADO.NET, ASP.NET, and HTML5/CSS3.
+
+
+
Zak Ruvalcaba has been researching, designing, and developing for the web since
+ 1995. His skill set ranges from HTML5/CSS3 and JavaScript/jQuery to .NET with VB
+ and C#, and he's created web applications for companies like HP, Toshiba, IBM,
+ Gateway, Intuit, Peachtree, Dell, and Microsoft. He has authored or co-authored our
+ books on HTML5/CSS3, jQuery, and Dreamweaver CC.
Due to our unique presentation methods and this book's modular organization,
+ this is the right book for any web developer who wants to use HTML5 and CSS3 effectively. That
+ includes:
+
+
budding web developers
+
web developers who haven't yet upgraded their websites to HTML5 and CSS3
+
web developers who need to expand and enhance their skillsets
+
+
+
+
As we see it, mastering HTML5 and CSS3 will make any web developer at any level more
+ effective.
+
+ Show more
+
+
+
+
+
+
diff --git a/html-java-script/week13/expand_collapse/subset_expansion.css b/html-java-script/week13/expand_collapse/subset_expansion.css
new file mode 100644
index 0000000..06eca0a
--- /dev/null
+++ b/html-java-script/week13/expand_collapse/subset_expansion.css
@@ -0,0 +1,35 @@
+* {
+ margin: 0;
+ padding: 0;
+}
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 87.5%;
+ width: 650px;
+ margin: 0 auto;
+ padding: 15px 25px;
+ border: 3px solid blue;
+}
+h1 {
+ font-size: 150%;
+}
+h2 {
+ font-size: 120%;
+ padding: .25em 0 .25em 25px;
+}
+div.hide {
+ display: none;
+}
+ul {
+ padding-left: 45px;
+}
+li {
+ padding-bottom: .4em;
+}
+p, a {
+ padding-bottom: .4em;
+ padding-left: 25px;
+}
+a, a:focus, a:hover {
+ color: blue;
+}
\ No newline at end of file
diff --git a/html-java-script/week13/expand_collapse/subset_expansion.js b/html-java-script/week13/expand_collapse/subset_expansion.js
new file mode 100644
index 0000000..79e8388
--- /dev/null
+++ b/html-java-script/week13/expand_collapse/subset_expansion.js
@@ -0,0 +1,23 @@
+"use strict"
+$(document).ready( () => {
+ //Grab all div next sibiling a
+ // Actually, could just do all a tags for this page
+ //Make the a toggle the hide class of it's previous sibiling element
+
+ $("a").click( evt => {
+ const a = evt.currentTarget;
+ $(a).prev().toggleClass("hide");
+
+ //If hidden, show more. Else, show less
+
+ if ($(a).prev().hasClass("hide")){
+ //Show More
+ $(a).text("Show More");
+
+ }
+ else{
+ //Show less
+ $(a).text("Show Less");
+ }
+ });
+});
diff --git a/html-java-script/week13/flexbox/LAB Recipe with flexbox.zip b/html-java-script/week13/flexbox/LAB Recipe with flexbox.zip
new file mode 100644
index 0000000..9d4c3ab
Binary files /dev/null and b/html-java-script/week13/flexbox/LAB Recipe with flexbox.zip differ
diff --git a/html-java-script/week13/flexbox/oatmealCookie_small.jpg b/html-java-script/week13/flexbox/oatmealCookie_small.jpg
new file mode 100644
index 0000000..f594f60
Binary files /dev/null and b/html-java-script/week13/flexbox/oatmealCookie_small.jpg differ
diff --git a/html-java-script/week13/flexbox/oatmeal_cookies.html b/html-java-script/week13/flexbox/oatmeal_cookies.html
new file mode 100644
index 0000000..65822a1
--- /dev/null
+++ b/html-java-script/week13/flexbox/oatmeal_cookies.html
@@ -0,0 +1,94 @@
+
+
+
+
+ binary eats - Oatmeal Coconut Pantry Cookies
+
+
+
+
+
+
Toast coconut at 350° F for about 10-15 minutes. Stir/toss every 5 minutes. Coconut should be golden brown. Be careful...coconut can go from golden brown to burnt very quickly. Cool completely.
+
Beat sugar, butter, vanilla, and eggs.
+
Mix all other ingredients together. The flour should coat all the ingredients. Then mix into the wet ingredients.
+
Scoop cookies and press the dough firmly the ensure the shape is held.
+
Bake at 375° F for about 9-13 minutes. This really depends on how big you made the cookies. Start at 9 minutes, and then just keep checking until they are done.
+
+
+
+
+
+
010 RELATED RECIPES:
+
+
Melt-in-the-mouth Cookies
+
German Chocolate Cake
+
+
+
+
TOP 011 RECIPES:
+
+
Umeboshi Chicken
+
Battleship Curry
+
Gran Marnier Souffle
+
+
+
+
+
+
\ No newline at end of file
diff --git a/html-java-script/week13/flexbox/styles.css b/html-java-script/week13/flexbox/styles.css
new file mode 100644
index 0000000..e7ffc9a
--- /dev/null
+++ b/html-java-script/week13/flexbox/styles.css
@@ -0,0 +1,82 @@
+/* Add your styles here */
+
+/* Given CSS rules below */
+body {
+ margin: 0;
+ font-family: Helvetica, sans-serif;
+}
+
+header {
+ border-bottom: 2px solid #93B5C6;
+ background-color: #DDEDAA;
+ padding: 8px;
+ display: flex;
+ justify-content: space-between;
+}
+
+.logo {
+ color: #BD4F6C;
+ font-size: 18px;
+}
+
+.content {
+ margin-left: 30px;
+ display: flex;
+ flex-wrap: wrap;
+}
+.main-content {
+ display: flex;
+ flex-wrap: wrap;
+ flex-grow: 1;
+ flex-basis: 70%;
+}
+
+.title {
+ border-bottom: 1px dashed #93B5C6;
+ display: flex;
+ align-items: baseline;
+}
+
+.title h1 {
+ color: #BD4F6C;
+}
+
+.title p {
+ color: #93B5C6;
+ margin-left: 30px;
+}
+
+.summary {
+ margin-top: 30px;
+ display: flex;
+ justify-content: space-evenly;
+ flex-grow: 1;
+ flex-basis: 100%;
+}
+
+.summary > div {
+ background-color: #DDEDAA;
+ border: 2px solid #93B5C6;
+ border-radius: 5px;
+ color: #BD4F6C;
+ padding: 5px;
+ width: 210px;
+}
+
+.summary > div > div{
+ display: flex;
+ justify-content: space-between;
+
+}
+
+.related-content {
+ margin-left: 100px;
+ flex-grow: 1;
+ flex-basis: 20%;
+}
+
+.ingredients, .directions{
+ flex-grow: 1;
+ flex-basis: 45%;
+}
+
diff --git a/java/final-project/.#Cvstranslate.java b/java/final-project/.#Cvstranslate.java
new file mode 120000
index 0000000..72ef37c
--- /dev/null
+++ b/java/final-project/.#Cvstranslate.java
@@ -0,0 +1 @@
+logen@logen.3256:1618517739
\ No newline at end of file
diff --git a/java/final-project/CovidDatabase.java b/java/final-project/CovidDatabase.java
index 20466cf..499d9b9 100644
--- a/java/final-project/CovidDatabase.java
+++ b/java/final-project/CovidDatabase.java
@@ -2,211 +2,326 @@ import java.util.ArrayList;
import java.util.Scanner;
import java.io.FileInputStream;
import java.util.Collections;
-
-
+import java.io.*;
+import java.sql.*;
public class CovidDatabase {
- private ArrayList list;
- private static final int SAFE = 5;
-
-
- public CovidDatabase() {
- list = new ArrayList();
- }
-
- private void transferCovidData(String filename){
-
-
- }
+ private ArrayList list;
+ private static final int SAFE = 5;
+ private static final String covidDB = "covid.db";
+ private static final String jdbcURL = "jdbc:sqlite:" + covidDB;
- public ArrayList topTenDeaths(int m, int d){
- ArrayList result = new ArrayList();
- ArrayList temp = getDailyDeaths(m, d);
+ public CovidDatabase() {
+ list = new ArrayList();
+ transferCovidData("covid_data.csv");
+ }
- Collections.sort(temp);
- if (temp.size() ==0){
+ private void transferCovidData(String filename) {
+
+ String csvFilePath = filename;
+
+ int batchSize = 20;
+
+ Connection connection = null;
+
+ try {
+
+ connection = DriverManager.getConnection(jdbcURL);
+ connection.setAutoCommit(false);
+ Statement makeTable = connection.createStatement();
+ makeTable.executeUpdate("drop table if exists entry");
+ makeTable.executeUpdate(
+ "create table entry (id integer, state string, month integer, day integer, daily_infections integer, daily_deaths integer, total_infections integer, total_deaths integer)");
+
+ String sql = "INSERT INTO entry (id, state, month, day, daily_infections, daily_deaths, total_infections, total_deaths) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ PreparedStatement statement = connection.prepareStatement(sql);
+
+ BufferedReader lineReader = new BufferedReader(new FileReader(csvFilePath));
+ String lineText = null;
+
+ int count = 0;
+
+ lineReader.readLine(); // skip header line
+ int id = 0;
+
+ while ((lineText = lineReader.readLine()) != null) {
+ String[] data = lineText.split(",");
+ String state = data[0];
+ int month = Integer.parseInt(data[1]);
+ int day = Integer.parseInt(data[2]);
+ int daily_infections = Integer.parseInt(data[3]);
+ int daily_deaths = Integer.parseInt(data[4]);
+ int total_infections = Integer.parseInt(data[5]);
+ int total_deaths = Integer.parseInt(data[6]);
+
+ statement.setInt(1, id);
+ statement.setString(2, state);
+ statement.setInt(3, month);
+ statement.setInt(4, day);
+ statement.setInt(5, daily_infections);
+ statement.setInt(6, daily_deaths);
+ statement.setInt(7, total_infections);
+ statement.setInt(8, total_deaths);
+
+ statement.addBatch();
+ id += 1;
+
+ if (count % batchSize == 0) {
+ statement.executeBatch();
+ }
+
+ }
+ lineReader.close();
+
+ // Print out the database for great justice
+ /*
+ * sql = "select * from entry";
+ *
+ * statement = connection.prepareStatement(sql); ResultSet rs =
+ * statement.executeQuery();
+ *
+ * while(rs.next()) { System.out.print("ID = " + rs.getString("id") + " ");
+ * System.out.print("State = " + rs.getString("state") + " ");
+ * System.out.print("Month = " + rs.getString("month") + " ");
+ * System.out.print("Day = " + rs.getString("day") + " ");
+ * System.out.print("Daily infected = " + rs.getString("daily_infections") +
+ * " "); System.out.print("Daily Death = " + rs.getString("daily_deaths") +
+ * " "); System.out.print("Total infected = " + rs.getString("total_infections")
+ * + " "); System.out.println("Total death = " + rs.getString("total_deaths"));
+ * }
+ */
+ // execute the remaining queries
+ statement.executeBatch();
+
+ connection.commit();
+ connection.close();
+
+ } catch (IOException ex) {
+ System.err.println(ex);
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+
+ try {
+ connection.rollback();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+
+ public ArrayList topTenDeaths(int m, int d) {
+ ArrayList result = new ArrayList();
+ ArrayList temp = getDailyDeaths(m, d);
+
+ Collections.sort(temp);
+ if (temp.size() == 0) {
+ return result;
+ }
+
+ for (int i = 0; i < 10; i++) {
+ result.add(temp.get(i));
+ }
return result;
}
- for (int i = 0; i < 10; i++){
- result.add(temp.get(i));
+ public ArrayList safeToOpen(String st) {
+ ArrayList result = new ArrayList();
+ int match = 0;
+ int previousDailyInfections = -1;
+
+ for (CovidEntry c : list) {
+ if (c.getState().equalsIgnoreCase(st)) {
+ if (previousDailyInfections == -1) {
+ previousDailyInfections = c.getDailyInfections();
+ match += 1;
+ } else if (c.getDailyInfections() < previousDailyInfections) {
+ match += 1;
+ } else {
+ match = 1;
+ result.clear();
+ }
+ result.add(c);
+
+ previousDailyInfections = c.getDailyInfections();
+ }
+ if (match == SAFE) {
+ return result;
+ }
+ }
+ return null;
}
- return result;
- }
- public ArrayList safeToOpen(String st){
- ArrayList result = new ArrayList();
- int match = 0;
- int previousDailyInfections = -1;
+ public ArrayList listMinimumDailyInfections(int m, int d, int min) {
+ ArrayList result = new ArrayList();
- for (CovidEntry c: list){
- if (c.getState().equalsIgnoreCase(st)) {
- if (previousDailyInfections == -1) {
- previousDailyInfections = c.getDailyInfections();
- match += 1;
+ for (CovidEntry c : list) {
+ if (c.getMonth() == m && c.getDay() == d && c.getDailyInfections() >= min) {
+ result.add(c);
+ }
}
- else if (c.getDailyInfections() < previousDailyInfections) {
- match += 1;
- } else {
- match = 1;
- result.clear();
- }
- result.add(c);
-
- previousDailyInfections = c.getDailyInfections();
- }
- if (match == SAFE) {
return result;
- }
}
- return null;
- }
- public ArrayList
- listMinimumDailyInfections(int m, int d, int min){
- ArrayList result = new ArrayList();
-
- for (CovidEntry c: list){
- if (c.getMonth() == m && c.getDay() == d && c.getDailyInfections() >= min){
- result.add(c);
- }
+ public int countRecords() {
+ return list.size();
}
- return result;
- }
-
- public int countRecords(){
- return list.size();
- }
- public int getTotalDeaths(){
- int result = 0;
+ public int getTotalDeaths() {
+ int result = 0;
- for (CovidEntry c: list){
- result += c.getDailyDeaths();
+ for (CovidEntry c : list) {
+ result += c.getDailyDeaths();
+ }
+ return result;
}
- return result;
- }
- public int getTotalInfections(){
- int result = 0;
+ public int getTotalInfections() {
+ int result = 0;
- for (CovidEntry c: list){
- result += c.getDailyInfections();
+ for (CovidEntry c : list) {
+ result += c.getDailyInfections();
+ }
+ return result;
}
- return result;
- }
- public int countTotalInfections(int m, int d){
- int result = 0;
+ public int countTotalInfections(int m, int d) {
+ int result = 0;
- for (CovidEntry c: list){
- if (c.getMonth() == m && c.getDay() == d){
- result += c.getDailyInfections();
- }
+ for (CovidEntry c : list) {
+ if (c.getMonth() == m && c.getDay() == d) {
+ result += c.getDailyInfections();
+ }
+ }
+ return result;
}
- return result;
- }
- public int countTotalDeaths(int m, int d){
- int result = 0;
+ public int countTotalDeaths(int m, int d) {
+ int result = 0;
- for (CovidEntry c: list){
- if (c.getMonth() == m && c.getDay() == d){
- result += c.getDailyDeaths();
- }
+ for (CovidEntry c : list) {
+ if (c.getMonth() == m && c.getDay() == d) {
+ result += c.getDailyDeaths();
+ }
+ }
+ return result;
}
- return result;
- }
-
-
- public ArrayList getDailyDeaths(int m, int d){
- ArrayList result = new ArrayList();
+ public ArrayList getDailyDeaths(int m, int d) {
+ ArrayList result = new ArrayList();
- for (CovidEntry c: list){
- if (c.getMonth() == m && c.getDay() == d){
- result.add(c);
- }
+ for (CovidEntry c : list) {
+ if (c.getMonth() == m && c.getDay() == d) {
+ result.add(c);
+ }
+ }
+ return result;
}
- return result;
- }
- //State
+ // State
public CovidEntry peakDailyDeaths(String st) {
- //iterate over our database
- //find highest deathcount that matches our state (st)
- CovidEntry result = null;
- int max = 0;
+ // iterate over our database
+ // find highest deathcount that matches our state (st)
+ CovidEntry result = null;
+ int max = 0;
- for(CovidEntry c : list){
- if( c.getState().equalsIgnoreCase(st)){
- if( c.getDailyDeaths() > max){
- max = c.getDailyDeaths();
- result = c;
- }
+ for (CovidEntry c : list) {
+ if (c.getState().equalsIgnoreCase(st)) {
+ if (c.getDailyDeaths() > max) {
+ max = c.getDailyDeaths();
+ result = c;
+ }
+ }
}
- }
- return result;
+ return result;
}
- //Month day
- public CovidEntry peakDailyDeaths(int m, int d) {
- //iterate over our database
- //find highest deathcount that matches our state (st)
- CovidEntry result = null;
- int max = 0;
+ // Month day
+ public CovidEntry peakDailyDeaths(int m, int d) {
+ // iterate over our database
+ // find highest deathcount that matches our state (st)
+ CovidEntry result = null;
+ int max = 0;
- for(CovidEntry c : list){
- if (c.getMonth() == m && c.getDay() == d) {
- if (c.getDailyDeaths() > max) {
- max = c.getDailyDeaths();
- result = c;
- }
+ for (CovidEntry c : list) {
+ if (c.getMonth() == m && c.getDay() == d) {
+ if (c.getDailyDeaths() > max) {
+ max = c.getDailyDeaths();
+ result = c;
+ }
+ }
}
- }
- return result;
- }
- public CovidEntry mostTotalDeaths(){
- CovidEntry result = null;
- int max = 0;
-
- for(CovidEntry c : list){
- if( c.getTotalDeaths() > max){
- max = c.getTotalDeaths();
- result = c;
- }
- }
- return result;
- }
-
- public void readCovidData(String filename){
- Scanner scnr = null;
- FileInputStream fs = null;
- try{
- fs = new FileInputStream(filename);
- scnr = new Scanner(fs);
- scnr.useDelimiter("[,\r\n]+");
- scnr.nextLine();
- while(scnr.hasNext()){
- String state = scnr.next();
- int month = scnr.nextInt();
- int day = scnr.nextInt();
- int di = scnr.nextInt();
- int dd = scnr.nextInt();
- int ti = scnr.nextInt();
- int td = scnr.nextInt();
-
- CovidEntry c = new CovidEntry(state,
- month, day, di, dd, ti, td);
- list.add(c);
- }
- fs.close();
- }
- catch(Exception e){
- System.out.println("File error with " + filename);
- }
-
+ return result;
}
+ public CovidEntry mostTotalDeaths() {
+ CovidEntry result = null;
+ int max = 0;
+
+ for (CovidEntry c : list) {
+ if (c.getTotalDeaths() > max) {
+ max = c.getTotalDeaths();
+ result = c;
+ }
+ }
+ return result;
+ }
+
+ /*
+ * public void readCovidData(String filename){ Scanner scnr = null;
+ * FileInputStream fs = null; try{ fs = new FileInputStream(filename); scnr =
+ * new Scanner(fs); scnr.useDelimiter("[,\r\n]+"); scnr.nextLine();
+ * while(scnr.hasNext()){ String state = scnr.next(); int month =
+ * scnr.nextInt(); int day = scnr.nextInt(); int di = scnr.nextInt(); int dd =
+ * scnr.nextInt(); int ti = scnr.nextInt(); int td = scnr.nextInt();
+ *
+ * CovidEntry c = new CovidEntry(state, month, day, di, dd, ti, td);
+ * list.add(c); } fs.close(); } catch(Exception e){
+ * System.out.println("File error with " + filename); }
+ *
+ * }
+ *
+ * }
+ */
+ public void readCovidData() {
+ CovidEntry entry;
+
+ Connection connection = null;
+ try {
+
+ connection = DriverManager.getConnection(jdbcURL);
+ connection.setAutoCommit(false);
+
+ String sql = "select * from entry";
+
+ PreparedStatement statement = connection.prepareStatement(sql);
+ ResultSet rs = statement.executeQuery();
+
+ while (rs.next()) {
+ String state = rs.getString("state");
+ int month = rs.getInt("month");
+ int day = rs.getInt("day");
+ int di = rs.getInt("daily_infections");
+ int dd = rs.getInt("daily_deaths");
+ int ti = rs.getInt("total_infections");
+ int td = rs.getInt("total_deaths");
+
+ entry = new CovidEntry(state, month, day, di, dd, ti, td);
+ list.add(entry);
+ }
+
+ connection.commit();
+ connection.close();
+ }
+
+ catch (SQLException ex) {
+ ex.printStackTrace();
+
+ try {
+ connection.rollback();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+ }
}
-
diff --git a/java/final-project/CovidDatabaseTest.java b/java/final-project/CovidDatabaseTest.java
index 0d646ff..d3466ca 100644
--- a/java/final-project/CovidDatabaseTest.java
+++ b/java/final-project/CovidDatabaseTest.java
@@ -1,41 +1,41 @@
public class CovidDatabaseTest {
- public static void main (String[] args) {
- System.out.println ("Testing starts");
- CovidDatabase db = new CovidDatabase() ;
- db.readCovidData("covid_data.csv");
- // check number of records, total infections, and total deaths
- assert db.countRecords() == 10346 : "database should have 10,346";
-
- assert db.getTotalDeaths() == 196696 : "Total deaths should be: 196,696";
- assert db.getTotalInfections() == 7032090 : "infections should be: 7,032,090";
- // check peak daily deaths for 5/5
- CovidEntry mostDeaths = db.peakDailyDeaths(5, 5);
- assert mostDeaths.getState().equals("PA") : "State with most deaths for 5/5 is PA";
- assert mostDeaths.getDailyDeaths() == 554 : "Deaths for 5/5 is PA: 554";
- // test other methods
+ public static void main(String[] args) {
+ System.out.println("Testing starts");
+ CovidDatabase db = new CovidDatabase();
+ db.readCovidData();
+ // check number of records, total infections, and total deaths
+ assert db.countRecords() == 10346 : "database should have 10,346";
- // Check highest deaths
- CovidEntry highestTX = db.peakDailyDeaths("TX");
- assert highestTX.getDailyDeaths() == 675 : "Highest texas deaths is: 675";
+ assert db.getTotalDeaths() == 196696 : "Total deaths should be: 196,696";
+ assert db.getTotalInfections() == 7032090 : "infections should be: 7,032,090";
+ // check peak daily deaths for 5/5
+ CovidEntry mostDeaths = db.peakDailyDeaths(5, 5);
+ assert mostDeaths.getState().equals("PA") : "State with most deaths for 5/5 is PA";
+ assert mostDeaths.getDailyDeaths() == 554 : "Deaths for 5/5 is PA: 554";
+ // test other methods
- // Most total deaths
- assert db.mostTotalDeaths().getTotalDeaths() == 25456 : "Highest deaths is 25456";
- assert db.mostTotalDeaths().getState().equals("NY") : "Highest deaths state: NY";
+ // Check highest deaths
+ CovidEntry highestTX = db.peakDailyDeaths("TX");
+ assert highestTX.getDailyDeaths() == 675 : "Highest texas deaths is: 675";
- // Peak daily deaths
- assert db.peakDailyDeaths("MI").getDailyDeaths() == 169 : "Highest MI Deaths: 169";
- assert db.peakDailyDeaths(5, 5).getDailyDeaths() == 554 : "Highest 5/5 deaths: PA";
+ // Most total deaths
+ assert db.mostTotalDeaths().getTotalDeaths() == 25456 : "Highest deaths is 25456";
+ assert db.mostTotalDeaths().getState().equals("NY") : "Highest deaths state: NY";
- // Top ten deaths
- assert db.topTenDeaths(5, 5).size() == 10 : "Top ten deaths should be 10";
- assert db.topTenDeaths(5, 5).get(0).getState().equals("PA") : "First Top ten deaths should be PA";
+ // Peak daily deaths
+ assert db.peakDailyDeaths("MI").getDailyDeaths() == 169 : "Highest MI Deaths: 169";
+ assert db.peakDailyDeaths(5, 5).getDailyDeaths() == 554 : "Highest 5/5 deaths: PA";
- // Safe to open
- assert db.safeToOpen("MI").get(0).getDailyInfections() == 443 : "First entry should have 443 infections";
+ // Top ten deaths
+ assert db.topTenDeaths(5, 5).size() == 10 : "Top ten deaths should be 10";
+ assert db.topTenDeaths(5, 5).get(0).getState().equals("PA") : "First Top ten deaths should be PA";
- //list min daily infections
- assert db.listMinimumDailyInfections(6,12,1000).get(0).getState().equals("TX") : "First entry should be TX";
+ // Safe to open
+ assert db.safeToOpen("MI").get(0).getDailyInfections() == 443 : "First entry should have 443 infections";
- System.out.println ("Testing ends");
- }
+ // list min daily infections
+ assert db.listMinimumDailyInfections(6, 12, 1000).get(0).getState().equals("TX") : "First entry should be TX";
+
+ System.out.println("Testing ends");
+ }
}
diff --git a/java/final-project/CovidEntry.java b/java/final-project/CovidEntry.java
index b7ddc8a..3f3fdbe 100644
--- a/java/final-project/CovidEntry.java
+++ b/java/final-project/CovidEntry.java
@@ -2,50 +2,63 @@ import java.text.DecimalFormat;
public class CovidEntry implements Comparable {
- //Private vars
- private String state;
- private int month, day;
- private int dailyDeaths, dailyInfections;
- private int totalDeaths, totalInfections;
- private static DecimalFormat df;
+ // Private vars
+ private String state;
+ private int month, day;
+ private int dailyDeaths, dailyInfections;
+ private int totalDeaths, totalInfections;
+ private static DecimalFormat df;
- //Constructor
- public CovidEntry(String st, int m, int d, int di, int dd,
- int ti, int td){
- this.state = st;
- this.month = m;
- this.day = d;
- this.dailyInfections = di;
- this.dailyDeaths = dd;
- this.totalDeaths = td;
- this.totalInfections = ti;
+ // Constructor
+ public CovidEntry(String st, int m, int d, int di, int dd, int ti, int td) {
+ this.state = st;
+ this.month = m;
+ this.day = d;
+ this.dailyInfections = di;
+ this.dailyDeaths = dd;
+ this.totalDeaths = td;
+ this.totalInfections = ti;
- df = new DecimalFormat("#,###,###");
- }
+ df = new DecimalFormat("#,###,###");
+ }
- //accessors
- public int getMonth(){return month;}
+ // accessors
+ public int getMonth() {
+ return month;
+ }
- public int getDay(){return day;}
+ public int getDay() {
+ return day;
+ }
- public String getState(){return state;}
+ public String getState() {
+ return state;
+ }
- public int getDailyInfections(){return dailyInfections;}
+ public int getDailyInfections() {
+ return dailyInfections;
+ }
- public int getDailyDeaths(){return dailyDeaths;}
+ public int getDailyDeaths() {
+ return dailyDeaths;
+ }
- public int getTotalDeaths(){return totalDeaths;}
+ public int getTotalDeaths() {
+ return totalDeaths;
+ }
- public int getTotalInfections(){return totalInfections;}
- public String toString(){
- return state + " " + month + "/" + day + " " +
- df.format(dailyInfections) + " infections, " +
- df.format(dailyDeaths) + " deaths";
- }
+ public int getTotalInfections() {
+ return totalInfections;
+ }
- public int compareTo(Object other){
- CovidEntry c = (CovidEntry) other;
- return c.dailyDeaths - dailyDeaths;
- }
+ public String toString() {
+ return state + " " + month + "/" + day + " " + df.format(dailyInfections) + " infections, "
+ + df.format(dailyDeaths) + " deaths";
+ }
+
+ public int compareTo(Object other) {
+ CovidEntry c = (CovidEntry) other;
+ return c.dailyDeaths - dailyDeaths;
+ }
}
diff --git a/java/final-project/CovidManager.java b/java/final-project/CovidManager.java
index d644750..24926f4 100644
--- a/java/final-project/CovidManager.java
+++ b/java/final-project/CovidManager.java
@@ -3,58 +3,51 @@ import java.util.ArrayList;
//time 11:10 - 11:22
//time 12:00 - 16:10
//time1 - 10:10 10:30
-
+//~11:30 - 15:30 -- didn't realize how to class path properly to include both
+//what I've done, and the jar file until seeing how intellij did it.
+//Web searches were not very helpful in this depot
public class CovidManager {
- public static void main( String[] args){
- CovidEntry covidObject =
- new CovidEntry("TX",
- 4, 12,
- 233343,
- 5,
- 10,
- 15);
- System.out.println(covidObject);
+ public static void main(String[] args) {
+ CovidEntry covidObject = new CovidEntry("TX", 4, 12, 233343, 5, 10, 15);
+ System.out.println(covidObject);
- CovidDatabase db = new CovidDatabase();
- db.readCovidData("data/covid_data.csv");
- System.out.println("highest daily d for texas");
- CovidEntry highestTX = db.peakDailyDeaths("TX");
- System.out.println(highestTX);
+ CovidDatabase db = new CovidDatabase();
+ db.readCovidData();
+ System.out.println("highest daily d for texas");
+ CovidEntry highestTX = db.peakDailyDeaths("TX");
+ System.out.println(highestTX);
- ArrayList may5th = db.getDailyDeaths(5, 5);
- System.out.println("May 5th Data");
- for (CovidEntry c: may5th){
- System.out.println(c);
+ ArrayList may5th = db.getDailyDeaths(5, 5);
+ System.out.println("May 5th Data");
+ for (CovidEntry c : may5th) {
+ System.out.println(c);
+ }
+
+ int totalInfections = db.getTotalInfections();
+ System.out.println("Total Infections " + totalInfections);
+
+ System.out.println("Total Records: " + db.countRecords());
+ System.out.println("Total Deaths: " + db.getTotalDeaths());
+ System.out.println("Total Deaths for May 5th: " + db.countTotalDeaths(5, 5));
+ System.out.println("Peak deaths for May 5th: " + db.peakDailyDeaths(5, 5));
+ System.out.println(
+ "Most total deaths: " + db.mostTotalDeaths() + " Total: " + db.mostTotalDeaths().getTotalDeaths());
+ System.out.println("States with less than 300 infections on may 5th: ");
+ may5th = db.listMinimumDailyInfections(5, 5, 300);
+ for (CovidEntry c : may5th) {
+ System.out.println(c);
+ }
+
+ System.out.println("WA safe to open: ");
+ ArrayList WASafe = db.safeToOpen("WA");
+ for (CovidEntry c : WASafe) {
+ System.out.println(c);
+ }
+
+ System.out.println("Top 10 deaths for May 1st");
+ ArrayList topTenDeaths = db.topTenDeaths(5, 1);
+ for (CovidEntry c : topTenDeaths) {
+ System.out.println(c);
+ }
}
-
- int totalInfections = db.getTotalInfections();
- System.out.println("Total Infections " + totalInfections);
-
- System.out.println("Total Records: " + db.countRecords());
- System.out.println("Total Deaths: " + db.getTotalDeaths());
- System.out.println("Total Deaths for May 5th: " + db.countTotalDeaths(5, 5));
- System.out.println("Peak deaths for May 5th: " + db.peakDailyDeaths(5, 5));
- System.out.println("Most total deaths: " + db.mostTotalDeaths() + " Total: " +
- db.mostTotalDeaths().getTotalDeaths());
- System.out.println("States with less than 300 infections on may 5th: ");
- may5th = db.listMinimumDailyInfections(5, 5, 300);
- for (CovidEntry c: may5th){
- System.out.println(c);
- }
-
- System.out.println("WA safe to open: ");
- ArrayList WASafe = db.safeToOpen("WA");
- for (CovidEntry c: WASafe){
- System.out.println(c);
- }
-
- System.out.println("Top 10 deaths for May 1st");
- ArrayList topTenDeaths = db.topTenDeaths(5, 1);
- for (CovidEntry c: topTenDeaths){
- System.out.println(c);
- }
-
- }
-
}
-
diff --git a/java/final-project/Lib/linux_start.sh b/java/final-project/Lib/linux_start.sh
new file mode 100755
index 0000000..a3f4eb9
--- /dev/null
+++ b/java/final-project/Lib/linux_start.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -cp /home/logen/programming/school/java/final-project/lib/sqlite-jdbc-3.34.0.jar test.java
diff --git a/java/final-project/Lib/sample.db b/java/final-project/Lib/sample.db
new file mode 100644
index 0000000..c812970
Binary files /dev/null and b/java/final-project/Lib/sample.db differ
diff --git a/java/final-project/Lib/sqlite-jdbc-3.34.0.jar b/java/final-project/Lib/sqlite-jdbc-3.34.0.jar
new file mode 100644
index 0000000..e3374e1
Binary files /dev/null and b/java/final-project/Lib/sqlite-jdbc-3.34.0.jar differ
diff --git a/java/final-project/Lib/test.java b/java/final-project/Lib/test.java
new file mode 100644
index 0000000..3629104
--- /dev/null
+++ b/java/final-project/Lib/test.java
@@ -0,0 +1,51 @@
+ import java.sql.Connection;
+ import java.sql.DriverManager;
+ import java.sql.ResultSet;
+ import java.sql.SQLException;
+ import java.sql.Statement;
+
+ public class Sample
+ {
+ public static void main(String[] args)
+ {
+ Connection connection = null;
+ try
+ {
+ // create a database connection
+ connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
+ Statement statement = connection.createStatement();
+ statement.setQueryTimeout(30); // set timeout to 30 sec.
+
+ statement.executeUpdate("drop table if exists person");
+ statement.executeUpdate("create table person (id integer, name string)");
+ statement.executeUpdate("insert into person values(1, 'leo')");
+ statement.executeUpdate("insert into person values(2, 'yui')");
+ ResultSet rs = statement.executeQuery("select * from person");
+ while(rs.next())
+ {
+ // read the result set
+ System.out.println("name = " + rs.getString("name"));
+ System.out.println("id = " + rs.getInt("id"));
+ }
+ }
+ catch(SQLException e)
+ {
+ // if the error message is "out of memory",
+ // it probably means no database file is found
+ System.err.println(e.getMessage());
+ }
+ finally
+ {
+ try
+ {
+ if(connection != null)
+ connection.close();
+ }
+ catch(SQLException e)
+ {
+ // connection close failed.
+ System.err.println(e.getMessage());
+ }
+ }
+ }
+ }
diff --git a/java/final-project/ScreenShots/coverpage.odt b/java/final-project/ScreenShots/coverpage.odt
new file mode 100644
index 0000000..50c0cb2
Binary files /dev/null and b/java/final-project/ScreenShots/coverpage.odt differ
diff --git a/java/final-project/ScreenShots/coverpage.pdf b/java/final-project/ScreenShots/coverpage.pdf
new file mode 100644
index 0000000..0f472bc
Binary files /dev/null and b/java/final-project/ScreenShots/coverpage.pdf differ
diff --git a/java/final-project/covid.db b/java/final-project/covid.db
new file mode 100644
index 0000000..e4d37c8
Binary files /dev/null and b/java/final-project/covid.db differ
diff --git a/java/final-project/linux_start.sh b/java/final-project/linux_start.sh
new file mode 100755
index 0000000..c6bbe06
--- /dev/null
+++ b/java/final-project/linux_start.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+javac *.java
+java -cp .:sqlite-jdbc-3.34.0.jar CovidManager
diff --git a/java/final-project/old/CvsTranslate.java b/java/final-project/old/CvsTranslate.java
new file mode 100644
index 0000000..f44ff41
--- /dev/null
+++ b/java/final-project/old/CvsTranslate.java
@@ -0,0 +1,102 @@
+// copyright by https://www.codejava.net
+import java.io.*;
+import java.sql.*;
+
+public class CvsTranslate {
+
+ public static void main(String[] args) {
+ String jdbcURL = "jdbc:sqlite:covid.db";
+
+ String csvFilePath = "covid_data.csv";
+
+ int batchSize = 20;
+
+ Connection connection = null;
+
+ try {
+
+ connection = DriverManager.getConnection(jdbcURL);
+ connection.setAutoCommit(false);
+ Statement makeTable = connection.createStatement();
+ makeTable.executeUpdate("drop table if exists entry");
+ makeTable.executeUpdate("create table entry (id integer, state string, month integer, day integer, daily_infections integer, daily_deaths integer, total_infections integer, total_deaths integer)");
+
+ String sql = "INSERT INTO entry (id, state, month, day, daily_infections, daily_deaths, total_infections, total_deaths) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
+ PreparedStatement statement = connection.prepareStatement(sql);
+
+ BufferedReader lineReader = new BufferedReader(new FileReader(csvFilePath));
+ String lineText = null;
+
+ int count = 0;
+
+ lineReader.readLine(); // skip header line
+ int id = 0;
+
+ while ((lineText = lineReader.readLine()) != null) {
+ String[] data = lineText.split(",");
+ String state = data[0];
+ int month = Integer.parseInt(data[1]);
+ int day = Integer.parseInt(data[2]);
+ int daily_infections = Integer.parseInt(data[3]);
+ int daily_deaths = Integer.parseInt(data[4]);
+ int total_infections = Integer.parseInt(data[5]);
+ int total_deaths = Integer.parseInt(data[6]);
+
+ statement.setInt(1, id);
+ statement.setString(2, state);
+ statement.setInt(3, month);
+ statement.setInt(4, day);
+ statement.setInt(5, daily_infections);
+ statement.setInt(6, daily_deaths);
+ statement.setInt(7, total_infections);
+ statement.setInt(8, total_deaths);
+
+ statement.addBatch();
+ id += 1;
+
+ if (count % batchSize == 0) {
+ statement.executeBatch();
+ }
+
+ }
+ lineReader.close();
+
+ // execute the remaining queries
+ statement.executeBatch();
+
+ // Print out the database for great justice
+ sql = "select * from entry";
+
+ statement = connection.prepareStatement(sql);
+ ResultSet rs = statement.executeQuery();
+
+ while(rs.next())
+ {
+ System.out.print("ID = " + rs.getString("id") + " ");
+ System.out.print("State = " + rs.getString("state") + " ");
+ System.out.print("Month = " + rs.getString("month") + " ");
+ System.out.print("Day = " + rs.getString("day") + " ");
+ System.out.print("Daily infected = " + rs.getString("daily_infections") + " ");
+ System.out.print("Daily Death = " + rs.getString("daily_deaths") + " ");
+ System.out.print("Total infected = " + rs.getString("total_infections") + " ");
+ System.out.println("Total death = " + rs.getString("total_deaths"));
+ }
+
+
+ connection.commit();
+ connection.close();
+
+ } catch (IOException ex) {
+ System.err.println(ex);
+ } catch (SQLException ex) {
+ ex.printStackTrace();
+
+ try {
+ connection.rollback();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ }
+}
diff --git a/java/final-project/old/run_translate.sh b/java/final-project/old/run_translate.sh
new file mode 100755
index 0000000..102b923
--- /dev/null
+++ b/java/final-project/old/run_translate.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -cp /home/logen/programming/school/java/final-project/lib/sqlite-jdbc-3.34.0.jar CvsTranslate.java
diff --git a/java/final-project/sqlite-jdbc-3.34.0.jar b/java/final-project/sqlite-jdbc-3.34.0.jar
new file mode 100644
index 0000000..e3374e1
Binary files /dev/null and b/java/final-project/sqlite-jdbc-3.34.0.jar differ
diff --git a/java/final-project/tests/CovidDatabaseJUnit.java b/java/final-project/tests/CovidDatabaseJUnit.java
new file mode 100644
index 0000000..5f088eb
--- /dev/null
+++ b/java/final-project/tests/CovidDatabaseJUnit.java
@@ -0,0 +1,267 @@
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import org.junit.*;
+/*******************************************
+ * Class to test the CovidDatabase project
+ *
+ * @author -
+ * @version -
+ ******************************************/
+public class CovidDatabaseJUnit{
+ /** object of the CovidDatabase class */
+ private CovidDatabase database;
+
+ /******************************************************
+ * Test constructor
+ *****************************************************/
+ @Test
+ public void testConstructor()
+ {
+ database= new CovidDatabase();
+ assertEquals("ArrayList should not contain any records at this time",
+ 0, database.countRecords ());
+ }
+
+ /******************************************************
+ * Test read file and counts
+ *****************************************************/
+ @Test
+ public void testReadFileAndCounts()
+ {
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+ assertEquals("ArrayList should not contain 10346 records",
+ 10346, database.countRecords ());
+ }
+
+ /******************************************************
+ * Test statics for all the covid entries
+ *****************************************************/
+ @Test
+ public void testStatistics()
+ {
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+
+ // testing total deaths
+ assertEquals("Total deaths up to 9/27 should be 196,696",
+ 196696, database.getTotalDeaths());
+
+ // testing total infections
+ assertEquals("Total infections up to 9/27 should be 7,032,090",
+ 7032090, database.getTotalInfections());
+
+ // testing most total infections
+ CovidEntry c = database.mostTotalDeaths();
+ assertEquals("State with most total deaths up to 9/27 is NY",
+ "NY", c.getState());
+ assertEquals("Number of deaths in NY up to 9/27: 25,456" ,
+ 25456, c.getTotalDeaths());
+ }
+
+ /******************************************************
+ * Test peak daily deaths
+ *****************************************************/
+ @Test
+ public void testPeakDailyDeaths()
+ {
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+ CovidEntry c;
+
+ // testing peak daily deaths for a date 8/12
+ c = database.peakDailyDeaths(8, 12);
+ assertEquals("State with peak deaths on 8/12 is TX",
+ "TX", c.getState());
+ assertEquals("Number deaths in TX on 8/12: 324" ,
+ 324, c.getDailyDeaths());
+
+ // testing peak daily deaths for a state
+ c = database.peakDailyDeaths("MI");
+ assertEquals("Peak deaths up to 9/27 in MI",
+ "MI", c.getState());
+ assertEquals("Peak number of deaths for MI: 169" ,
+ 169, c.getDailyDeaths());
+
+ // testing peak daily deaths for a date 4/30
+ c = database.peakDailyDeaths(4, 30);
+ assertEquals("State with peak deaths on 4/30 is NJ",
+ "NJ", c.getState());
+ assertEquals("Number deaths in NJ on 4/30: 481" ,
+ 481, c.getDailyDeaths());
+
+ // testing peak daily deaths for a state
+ c = database.peakDailyDeaths("NY");
+ assertEquals("Peak deaths up to 9/27 in NY",
+ "NY", c.getState());
+ assertEquals("Peak number of deaths for NY: 951" ,
+ 951, c.getDailyDeaths());
+
+ }
+
+ /******************************************************
+ * Test peak daily deaths - invalid state & invalid date
+ *****************************************************/
+ @Test
+ public void testPeakDailyDeathsInvalidParameters()
+ {
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+ CovidEntry c;
+
+ // testing peak daily deaths for an invalid date
+ c = database.peakDailyDeaths(13, 12);
+ assertEquals("Wrong date 13/12 should return null",
+ null, c);
+
+ // testing peak daily deaths for an invalid state
+ c = database.peakDailyDeaths("XX");
+ assertEquals("Wrong state XX should return null" ,
+ null, c);
+
+ // testing peak daily deaths for date not found in the file
+ c = database.peakDailyDeaths(1, 1);
+ assertEquals("No records for 1/1 should return null",
+ null, c);
+ }
+
+ /******************************************************
+ * Test safe to open
+ *****************************************************/
+ @Test
+ public void testSafeToOpen() {
+ ArrayList list;
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+
+ // testing safe to open WA
+ list = database.safeToOpen("WA");
+ assertEquals("Safe to open should have 5 records" ,
+ 5, list.size());
+
+ //testing first record on the list
+ assertEquals("The states should be WA",
+ "WA", list.get(0).getState());
+ assertEquals("Month in the first record in the sequence should be 5",
+ 5, list.get(0).getMonth());
+ assertEquals("Day in the first record in the sequence should be 6",
+ 6, list.get(0).getDay());
+ assertEquals("Infections in the first record in the sequence whould be 289",
+ 289, list.get(0).getDailyInfections());
+
+ //testing last record on the list
+ assertEquals("The states should be WA",
+ "WA", list.get(4).getState());
+ assertEquals("Month in the lasst record in the sequence should be 5",
+ 5, list.get(4).getMonth());
+ assertEquals("Day in the last record in the sequence should be 10",
+ 10, list.get(4).getDay());
+ assertEquals("Infections in the last record in the sequence whould be 62",
+ 62, list.get(4).getDailyInfections());
+
+ // test safe to open - California
+ list = database.safeToOpen("CA");
+ assertEquals("Safe to open should have 5 records" ,
+ 5, list.size());
+
+ //testing first record on the list
+ assertEquals("The states should be CA",
+ "CA", list.get(0).getState());
+ assertEquals("Month in the first record in the sequence should be 5\4",
+ 4, list.get(0).getMonth());
+ assertEquals("Day in the first record in the sequence should be 21",
+ 21, list.get(0).getDay());
+ assertEquals("Infections in the first record in the sequence whould be 2283",
+ 2283, list.get(0).getDailyInfections());
+
+ //testing last record on the list
+ assertEquals("The states should be CA",
+ "CA", list.get(4).getState());
+ assertEquals("Month in the lasst record in the sequence should be 4",
+ 4, list.get(4).getMonth());
+ assertEquals("Day in the last record in the sequence should be 25",
+ 25, list.get(4).getDay());
+ assertEquals("Infections in the last record in the sequence whould be 1883",
+ 1883, list.get(4).getDailyInfections());
+
+ // testing a state not found in the database
+ list = database.safeToOpen("ZZ");
+ assertEquals("State not valid - safeToOpen should return null" ,
+ null, list);
+ }
+
+ /******************************************************
+ * Test minimum infections on a date
+ *****************************************************/
+ @Test
+ public void testMinInfections() {
+ ArrayList list;
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+
+ // testing a Minimum of 2,500 infections on 9/11
+ list = database.listMinimumDailyInfections(9, 11, 2500);
+ assertEquals("three records with 2,500 infections or more on 9/11" ,
+ 3, list.size());
+
+ //testing highest - index 0
+ assertEquals("TX should have the highest number of deaths on 8/1",
+ "TX", list.get(0).getState());
+ assertEquals("Infections in TX on 9/11 should be 3547",
+ 3547, list.get(0).getDailyInfections());
+
+ //testing last entry
+ assertEquals("CA should be the last entry on the list",
+ "CA", list.get(2).getState());
+ assertEquals("Infections in CA on 9/11 should be 3326",
+ 3326, list.get(2).getDailyInfections());
+
+ // testing parameter values not found in database
+ list = database.listMinimumDailyInfections(9, 11, 6000);
+ assertEquals("Infections of 6,000 or more on 9/11 hould be zero" ,
+ 0, list.size());
+
+ // testing wrong parameter values
+ list = database.listMinimumDailyInfections(13, 11, 10);
+ assertEquals("Invalid date 13/11 Infections of 10 or more on 9/11 hould be zero" ,
+ 0, list.size());
+ }
+
+ /******************************************************
+ * Test top ten
+ *****************************************************/
+ @Test
+ public void testTopTen() {
+ ArrayList list;
+ database= new CovidDatabase();
+ database.readCovidData("covid_data.csv");
+
+ // testing top ten for 8/1
+ list = database.topTenDeaths(8, 1);
+ assertEquals("top ten number of records should be 10" ,
+ 10, list.size());
+
+ //testing highest - index 0
+ assertEquals("TX should have the highest number of deaths on 8/1",
+ "TX", list.get(0).getState());
+ assertEquals("Deaths in TX on 8/1 should be 268",
+ 268, list.get(0).getDailyDeaths());
+
+ //testing CovidEntry at index 6
+ assertEquals("NC should be at index 6 of the list of deaths on 8/1",
+ "NC", list.get(6).getState());
+ assertEquals("Deaths in NC on 8/1 should be 40",
+ 40, list.get(6).getDailyDeaths());
+
+ // testing a date not found in the database
+ list = database.topTenDeaths(10, 31);
+ assertEquals("top ten number of records should be zero" ,
+ 0, list.size());
+
+ // testing an invalid date
+ list = database.topTenDeaths(-10, 31);
+ assertEquals("top ten number of records should be zero" ,
+ 0, list.size());
+ }
+}
+
diff --git a/java/final-project/tests/CovidEntryJUnit.java b/java/final-project/tests/CovidEntryJUnit.java
new file mode 100644
index 0000000..6daf1c8
--- /dev/null
+++ b/java/final-project/tests/CovidEntryJUnit.java
@@ -0,0 +1,43 @@
+import static org.junit.Assert.*;
+import org.junit.*;
+/*******************************************
+ * Class to test the CovidEntry class
+ *
+ * @author -
+ * @version -
+ ******************************************/
+public class CovidEntryJUnit{
+ /** object of the CovidEntry class*/
+ private CovidEntry covid;
+
+ /******************************************************
+ * Test constructor
+ *****************************************************/
+ @Test
+ public void testConstructor() {
+ //Testing a female baby name
+ covid = new CovidEntry("MI",8,1,758,7,91332,6457);
+
+ assertEquals("Constructor: State should be equal to value of input parameter",
+ "MI", covid.getState());
+
+ assertEquals("Constructor: month should be equal to value of input parameter",
+ 8, covid.getMonth());
+
+ assertEquals("Constructor: day should be equal to value of input parameter",
+ 1, covid.getDay());
+
+ assertEquals("Constructor: daily infections should be equal to value of input parameter",
+ 758, covid.getDailyInfections());
+
+ assertEquals("Constructor: daily deaths should be equal to value of input parameter",
+ 7, covid.getDailyDeaths());
+
+ assertEquals("Constructor: total infections should be equal to value of input parameter",
+ 91332, covid.getTotalInfections());
+
+ assertEquals("Constructor: total deaths should be equal to value of input parameter",
+ 6457, covid.getTotalDeaths());
+
+ }
+}
diff --git a/temp/a.out b/temp/a.out
new file mode 100755
index 0000000..1a2a5dc
Binary files /dev/null and b/temp/a.out differ
diff --git a/temp/main.cpp b/temp/main.cpp
new file mode 100644
index 0000000..658e25b
--- /dev/null
+++ b/temp/main.cpp
@@ -0,0 +1,23 @@
+#include
+#include
+#include
+using namespace std;
+
+int main() {
+ string object1Info = "Pencil 5 4";
+ string object2Info = "Notepad 13 12";
+ string object3Info = "Headphones 23 26";
+
+ istringstream objectISS(object1Info);
+
+ string object;
+ int quantity;
+ int price;
+
+ objectISS >> object >> quantity >> price;
+
+ cout << object << " x" << quantity << endl;
+ cout << "Price: " << price;
+
+ return 0;
+}