Project 1 Worker class:
A Worker has the following three fields:
String name, int yearsOfExperience, booealn degreeInField
Provide:
1) an initialize constructor
2) accessors/modifiers
3) equals method that overrides the method from Object class
4) toString method
Job class:
A job “has-an” array of Worker objects.
Provide:
1) An initialize constructor (make sure to copy values into field)
2) accessors
3) a method called nameOfWorkerWithMostExperience that returns the name of the worker who has the most years of experience
4) a method called averageYearsOfExperience that returns the average years of experience for the workers
5) a method called numberOfYearsAboveAverage that returns an array of double values that represent how many more years the worker has worked than average
i.e. worker hours: 5, 15, 8, 12, 20
method should return -7, 3, -4, 0, 8
6) a toString method that displays all the workers at the Job. Take advantage of the toString method supplied for the Worker class.
Project 2 Gradebook Class
Gradebook Project
Create a class called Test. A Test object will contain the grade scored on the Test and whether the student completed the H.W. for the test.
Test probability = new Test(85, true);
The above example represents a student completing the HW for the test and earning an 85 on the test.
Provide a) no-args constructor and initialize constructor
b) accessors and modifiers
toString() method that returns (for example: grade = 85, h.w. = true)
Gradebook class:
A Gradebook will have one field: private Test[][] tests;
Each row of the 2-D array represents the grades for a single student for a given year.
i.e.
85, true 70, false 65, false 77, true
98, true 79, true 60, false 65, false
88, false 88, true 80, true 90, true
…..
….
….
….
Gradebook class should provide an initialize constructor. The constructor will accept a 2-D array of Test objects and initialize the field. Remember you should copy the elements in this array, not just assign the dummy variable to the field (understand why).
The Gradebook class should have the following methods:
double[] studentAverages()//returns the averages for each student
double[] testAverages()//returns the averages for each test
int indexOfHighestStudent()//returns the index of the student with the highest average
int indexOfLowestTest()//returns the index of the test that has the lowest average
int highestTest()//returns the grade of the highest test from any assignment
(i.e. = 98 from the example above)
boolean didLowestTestStudentDoHw()//returns true if the student with the very lowest test attempted the h.w. for the test
double differenceInAveragesBetweenHWAndNoHW()//returns the difference in the average test grade for students who completed HW vs. students who did not complete HW.
Project 3
Candidate class
private String name;
private int yearsofExperience;
private boolean degreeInField;
private double salaryExpectation; //in $ per hour
Initialize Constructor
Accessors/Modifiers
int value() // Candidates are more valuable if they have more years of Experience and a degree in field. Having a degree in the field is worth 50 points and then 5 points for every year of experience.
String toString()
i.e. Craig Sapp has a degree in field with 8 years of experience.
Interview class:
private ArrayList<Candidate> candidates;
Initialize constructor
Accessors/Modifiers
Candidate getHighestValuedCandidate()
double getAverageYearsOfExperience()
double getLowestSalaryExpectation()
String toString()
//Jeff Johnson is the winning candidate. He has 4 more years of experience than the average and expects to be paid $24 an hour.
Project 4: PIXLAB (done together in class)
Project 5:
import java.awt.*;
import java.util.*;
public class Tester
{
public static void main(String[] args)
{
ArrayList<Color> colors = new ArrayList<Color>();
colors.add(new Color(200, 200, 100));
colors.add(new Color(150, 160, 110));
colors.add(new Color(90, 80, 70));
colors.add(new Color(100, 110, 50));
System.out.println(closestToGray(colors));
}
public static Color closestToGray(ArrayList<Color> cs)
{
//implement code here to return the Color object in cs that is closest to gray (i.e. smallest range between red, green, and blue)
//The Color above that is closest to gray would be 90, 80, 70
}
Project 6:
Create a class called Student that implements a compareTo method.
Students will have three fields: First Name, Last Name, and Period
The class should compare this student to another by comparing their period number; if they are equal it should compare their last names; if they are equal it should compare their first names
Copy the following tester class:
import java.util.ArrayList;
public class StudentTester
{
public static void main(String[] args)
{
ArrayList<Student> students = new ArrayList<Student>();
students.add(new Student("Jeff", "Adams", 1));
students.add(new Student("Jill", "Henderson", 3));
students.add(new Student("Craig", "Taylor", 5));
students.add(new Student("Joe", "Thomas", 1));
students.add(new Student("Betsy", "Durrence", 1));
students.add(new Student("Dina", "Jenkins", 5));
students.add(new Student("Thomas", "Clowney", 1));
students.add(new Student("Tracey", "Martin", 1));
students.add(new Student("Ted", "Sapp", 5));
students.add(new Student("Brianna", "Sapp", 5));
students.add(new Student("David", "Medrano", 3));
students.add(new Student("Brianna", "Brunson", 5));
students.add(new Student("Peter", "Keevey", 1));
students.add(new Student("Jan", "Martin", 1));
}
}
· Create an array (not ArrayList) called students2. Copy all the student from the students ArrayList in to the students2 array.
· Create a student Student a = new Student(“Joe”, “Thomas”, 1);
· Create a method in the tester class called sequentialSearch.
· Call the method sequentialSearch to search the students ArrayList for Student a. It should return and print 3.
· Create a method in the tester class called selectionSort
· Sort the students in the students ArrayList.
· Print out the sorted students ArrayList to see that they are first sorted by period and then by last name and then by first name
· Create a method in the tester class called binarySearch.
· Call the method binarySearch to search the students ArrayList for Jill Henderson from 3rd period.
· Create a method in the tester class called insertionSort
· Sort the students in the students2 array.
· Print out the sorted students2 array to see that they are first sorted by period and then by last name and then by first name