inital commit

This commit is contained in:
gabriel venberg 2021-03-26 22:45:38 -05:00
commit aa37ae1eec
55 changed files with 3927 additions and 0 deletions

1
lab10/dist/javadoc/element-list vendored Normal file
View file

@ -0,0 +1 @@
unnamed package

69
lab10/src/Course.java Normal file
View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2020 Gabriel Venberg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* @author toric
*/
public class Course {
private int courseID;
private int credits;
private String instructorName;
public Course( int startCourseID, int startCredits, String startInstructorName){
courseID = startCourseID;
credits=startCredits;
instructorName=startInstructorName;
}
/**
* returns courseID
* @return
*/
public int getCourseID(){
return courseID;
}
/**
* returns credits
* @return
*/
public int getCredits(){
return credits;
}
/**
* returns instructorName
* @return
*/
public String getInstructorName(){
return instructorName;
}
/**
* outputs data about course as a string.
* @return
*/
public String toString(){
return ("courseID: "+courseID+", credits: "+credits+", instructor: "+instructorName);
}
/**
* compares for equality with another course.
* @param testCourse
* @return
*/
public boolean equals(Course testCourse){
return testCourse.getCourseID()==courseID&testCourse.getCredits()==credits
&testCourse.getInstructorName().equals(instructorName);
}
}

85
lab10/src/NFLstats.java Normal file
View file

@ -0,0 +1,85 @@
/*
* Copyright (C) 2020 Gabriel Venberg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*I know nothing about football, and especially nothing about football stats...
*
* @author toric
*/
import java.util.Scanner;
import java.text.NumberFormat;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class NFLstats {
public static void main(String[] args) throws FileNotFoundException, IOException {
// initalizing.
File inputFile = new File("stats.txt");
Scanner file = new Scanner(inputFile);
NumberFormat percentFormat = NumberFormat.getPercentInstance();
//getting file line size, to instatiate array.
Path path = Paths.get("stats.txt");
//first line defines columns.
int lines = (int) Files.lines(path).count() - 1;
double[] yards = new double[lines];
int[] attempts = new int[lines];
int[] completions = new int[lines];
double[] yardsPerAttempt = new double[lines];
double[] completionPercentage = new double[lines];
int highYardGames = 0;
final double highYardThreshold = 275;
double totalYards = 0;
double highYards = 0;
//skip the first line, first line contains colum defs.
/*why am I reading all this info from a file, you might ask? well, this assignment didnt tell me what input method to use.
i didnt want to hardcode it, and no way was i entering all that data manually every run.*/
file.nextLine();
for (int i = 0; i < lines; i++) {
String line = file.nextLine();
String[] data = line.split(",");
//column order is game,attempts,completions,yards. not using game this program.
attempts[i] = Integer.parseInt(data[1]);
completions[i] = Integer.parseInt(data[2]);
yards[i] = Double.parseDouble(data[3]);
}
//we can put all the arrayprocessing in one loop.
for (int i = 0; i < yards.length; i++) {
//System.out.println(yards[i] + "," + completions[i] + "," + attempts[i]);
totalYards = totalYards + yards[i];
completionPercentage[i] = (double)completions[i] / (double)attempts[i];
yardsPerAttempt[i] = yards[i] / attempts[i];
if (yards[i] >= highYardGames) {
highYardGames++;
}
highYards = Math.max(yards[i], highYards);
}
//print stuff. not sure why you only had us print a few of the completed values...
for (int i = 0; i < completionPercentage.length; i++) {
System.out.println("Game " + (i + 1) + " had a completion percentage of " + percentFormat.format(completionPercentage[i]));
}
System.out.println("The most yards thrown during any game was " + highYards + ".");
}
}

132
lab10/src/Student.java Normal file
View file

@ -0,0 +1,132 @@
/*
* Copyright (C) 2020 Gabriel Venberg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* @author toric
*/
public class Student {
private int studentID;
private double GPA;
private String name;
private char gender;
private Course courseList[];
private static int nextID = 1000;
public Student(String startName, char startGender, Course [] startCourseList){
studentID=nextID;
nextID++;
GPA=0.0;
name=startName;
gender=startGender;
courseList =new Course[startCourseList.length];
for (int i=0; i<startCourseList.length; i++){
courseList[i]=startCourseList[i];
}
}
/**
* returns studentID
* @return
*/
public int getStudentID(){
return studentID;
}
/**
* returns GPA
* @return
*/
public double getGPA(){
return GPA;
}
/**
* returns name
* @return
*/
public String getName(){
return name;
}
/**
* returns gender
* @return
*/
public char getGender(){
return gender;
}
/**
* returns the students course list.
* @return
*/
public Course [] getCourseList(){
Course [] tmp = new Course [courseList.length];
for (int i=0; i<courseList.length; i++){
tmp[i]=courseList[i];
}
return tmp;
}
/**
* sets the students name
* @param newName
*/
public void setName(String newName){
name=newName;
}
/**
* sets the students GPA
* @param newGPA
*/
public void setGPA(double newGPA){
GPA=newGPA;
}
/**
* sets the students gender
* @param newGender
*/
public void setGender(char newGender){
gender=newGender;
}
/**
* sets the students course list.
* @param newCourseList
*/
public void setCourseList(Course [] newCourseList){
for (int i=0; i<newCourseList.length; i++){
courseList[i]=newCourseList[i];
}
}
/**
* returns data in human readable string
* @return
*/
public String toString(){
String courseListString = "";
for (int i=0; i<courseList.length; i++){
courseListString=courseListString+", "+courseList[i].toString();
}
return "Student ID: "+studentID+", name: "+name+", gender: "+gender+" GPA: "+GPA+
", Course List: "+courseListString;
}
/**
* tests for equality with another student object. courses must be in the same order.
* @param testStudent
* @return
*/
public boolean equals(Student testStudent){
return studentID==testStudent.getStudentID()&GPA==testStudent.getGPA()
&testStudent.getName().equals(name)&testStudent.getGender()==gender
&testStudent.getCourseList().equals(courseList);
}
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020 Gabriel Venberg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
*
* @author toric
*/
public class StudentTest {
public static void main(String[] args){
Course CS1 = new Course(160, 4, "Pratap Kotala");
Course linearAlgebra = new Course(129, 4, "Michal Roberts");
Course startCourseList[]={CS1, linearAlgebra};
Student johnDoe = new Student ("John Doe", 'm', startCourseList);
startCourseList[0]=linearAlgebra; startCourseList[1]=CS1;
Student johnDoe2 = new Student ("John Doe", 'm', startCourseList);
//the only interesting thing about this class is that equals is order sensitive witht the course list.
System.out.println(johnDoe.equals(johnDoe2));
}
}

18
lab10/stats.txt Normal file
View file

@ -0,0 +1,18 @@
game,attempts,completions,yards
08/15/19,14,10,118
08/22/19,14,9,74
09/08/19,46,33,304
09/15/19,43,27,320
09/22/19,34,29,304
09/29/19,53,35,397
10/06/19,46,32,330
10/13/19,36,30,356
10/20/19,27,16,159
11/10/19,35,20,182
11/17/19,31,21,311
11/24/19,46,23,271,
11/28/19,50,35,312,
12/08/19,34,20,313,
12/15/19,39,25,210,
12/22/19,45,32,384,
12/29/19,51,30,313,