Initial Commit

This commit is contained in:
2012-01-22 16:14:32 -05:00
commit f5e306f67f
155 changed files with 5097 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>StudentLedger</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,12 @@
#Sun Jan 22 14:47:15 EST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,135 @@
/**
* @author Twenty Codes, LLC
* @author ricky barrette
* @date Nov 21, 2010
*/
import java.util.ArrayList;
/**
* this will be a student ledger for grading students
* @author ricky barrette
*/
public class Ledger {
private ArrayList<Integer> mGradeList;
private String mStudentName;
/**
*
* Creates a new Ledger
* @param studentName
* @author ricky barrette
*/
public Ledger(String studentName) {
mGradeList = new ArrayList<Integer>();
mStudentName = studentName;
}
/**
* Creates a new Ledger
* @param studentName
* @param gradeList
* @author ricky barrette
*/
public Ledger(String studentName, ArrayList<Integer> gradeList) {
mGradeList = new ArrayList<Integer>();
addGrades(gradeList);
mStudentName = studentName;
}
/**
* Creates a new Ledger
* @param studentName
* @param gradeList
* @author ricky barrette
*/
public Ledger(String studentName, int[] gradeList) {
mGradeList = new ArrayList<Integer>();
addGrades(gradeList);
mStudentName = studentName;
}
/**
* Adds grades from an array
* @param gradeList
* @return the list of invalid grades, or null
* @author ricky barrette
*/
public ArrayList<Integer> addGrades (int[] gradeList){
ArrayList<Integer> badList = new ArrayList<Integer>();
for(int item : gradeList){
if(! addGrade(item)){
badList.add(item);
}
}
if(badList.size() != 0)
return badList;
return null;
}
/**
* adds grades from a list
* @param gradeList
* @return the list of inValid grades, or null
* @author ricky barrette
*/
public ArrayList<Integer> addGrades (ArrayList<Integer> gradeList){
ArrayList<Integer> badList = new ArrayList<Integer>();
for(int item : gradeList){
if(! addGrade(item)){
badList.add(item);
}
}
if(badList.size() != 0)
return badList;
return null;
}
/**
* adds a new grade to the grade list if valid
* @param newGrade
* @return true if the grade was added
* @author ricky barrette
*/
public boolean addGrade(int newGrade){
if(newGrade >= 0 && newGrade <= 100){
mGradeList.add(newGrade);
return true;
}
System.out.println(newGrade +" is an invalid grade");
return false;
}
/**
* gets all the grades for this student
* @return an array containing all the grades
* @author ricky barrette
*/
public ArrayList<Integer> getGrades(){
return mGradeList;
}
/**
* returns the name of the student
* @return student's name
* @author ricky barrette
*/
public String getStudentName(){
return mStudentName;
}
/**
* computes the average grade of the student
* @return the students current average
* @author ricky barrette
*/
public int getAverage(){
int total = 0;
int count;
for(count = 0; count < mGradeList.size(); count++){
total = total + mGradeList.get(count);
}
return total / count;
}
}

View File

@@ -0,0 +1,49 @@
/**
* @author Twenty Codes, LLC
* @author ricky barrette
* @date Nov 22, 2010
*/
/**
* this will be the driver class to test the Ledger
* @author ricky barrette
*/
public class Students {
private int[] startingGrades = new int[] { 90, 75, 100, 60, 90, 92, 96, 100, 42, 100 };
/**
* Creates a new Students
* @author ricky barrette
*/
public Students() {
Ledger student1 = new Ledger("Student 1", startingGrades);
System.out.println(student1.getAverage());
student1.addGrade(100);
System.out.println(student1.getAverage());
int[] semester2 = new int[] { 90, 80, 70, 100, 101, 90, 90 };
System.out.println(student1.addGrades(semester2).get(0));
System.out.println(student1.getAverage() +"\n");
for(int item : student1.getGrades()){
System.out.print(item+", ");
}
System.out.println("\n"+student1.getAverage());
}
/**
* main method, called when the application starts
* @param args
* @author ricky barrette
*/
public static void main(String[] args) {
new Students();
}
}