class Student
{
private String firstName;
private String lastName;
private Address homeAddress;
private Address schoolAddress;
private int test1;
private int test2;
private int test3;
public Student (String first, String last, Address home, Address school)
{
lastName=last;
firstName=first;
homeAddress=home;
schoolAddress=school;
test1=0;
test2=0;
test3=0;
}
public void setTestScore (int testNumber, int testScore)
{
if (testNumber == 1)
test1 = testScore;
else if (testNumber == 2)
test2 = testScore;
else
test3 = testScore;
}
public int getTestScore(int testNumber)
{
if (testNumber == 1)
return test1;
else if (testNumber == 2)
return test2;
else
return test3;
}
public double getAverage()
{
return (test1 + test2 + test3)/3;
}
public String toString()
{
String result = firstName +"\n"+ lastName +"\n"+
"HomeAddress: "+ homeAddress + "\n"+
"schoolAddress: "+ schoolAddress + "\n"+
"test1: " + "test 1" + "\n"+
"test2: " + "test 2" + "\n"+
"test3: " + "test 3" + "\n"+
"average: " +this.getAverage()+"\n";
return result;
}
}
class Course
{
static int numberStudent = 0;
String title;
Student student1;
Student student2;
Student student3;
Student student4;
Student student5;
public Course(String courseTitle)
{
title=courseTitle;
}
public void addStudent(String first, String last, Address home, Address school)
{
switch(numberStudent)
{
case 0: student1 = new Student(first,last,home,school);
case 1: student2 = new Student(first,last,home,school);break;
case 2: student3 = new Student(first,last,home,school);break;
case 3: student4 = new Student(first,last,home,school);break;
case 4: student5 = new Student(first,last,home,school);break;
default: System.out.println("No More students allowed in the class");
}
numberStudent++;
}
public String toString()
{
String results="";
results += student1.toString () +"n";
results += student2.toString () +"n";
results += student3.toString () +"n";
results += student4.toString () +"n";
results += student5.toString () +"n";
return results;
}
class Address
{
private String streetAddress;
private String city;
private String state;
private long zipCode;
public Address(String stAddress,String cityValue,String stateValue,long zip)
{
streetAddress = stAddress;
city = cityValue;
state = stateValue;
zipCode = zip;
}
}