Created
August 19, 2012 19:48
-
-
Save breeze4/3397249 to your computer and use it in GitHub Desktop.
insaneclownkitty student
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
//declare variables that will be used | |
private String firstname; | |
private String lastname; | |
private int studentID; | |
private double[] projects; | |
private double[] quizzes; | |
public Student(String first, String last, int id) { | |
//instantiate variables with parameters from the constructor | |
firstname = first; | |
lastname = last; | |
studentID = id; | |
projects = new double[15]; | |
quizzes = new double[10]; | |
//length of projects is 15, so i should go from 14 to 0 | |
int i = this.projects.length - 1; | |
while (i >= 0){ | |
this.projects[i] = -1; //set the project score to -1 | |
i--; //decrement i | |
} | |
//length of quizzes is 10, so i should go from 9 to 0 | |
int i = this.quizzes.length - 1; | |
while (i >= 0){ | |
this.quizzes[i] = -1; //set the quiz score to -1 | |
i--; //decrement i | |
} | |
} | |
public int getNextQuizIndex(){ | |
int i = 0; | |
do { | |
if (quizzes[i] == -1.0){ | |
return i; //found the next quiz that needs a score filled in | |
} | |
i++; | |
} while (i < quizzes.length); | |
return -1; //quiz array is full! | |
} | |
public boolean setQuizScore(double quizScore, int quizID){ | |
if ((quizID >= quizzes.length) || (quizID < 0)) { | |
return false; | |
} | |
else { | |
quizzes[quizID] = quizScore; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment