Before you read on this is for my homework and will be oddly specific.
I am very new to object-oriented programming and currently, it is very hard for me to grasp the new concepts. My assignment is to get information from object classes with two files. One file is for encapsulating the functions while the other file is to implement the functions and execute the code (the public static void file). So for the part that I am stuck on, I am unsure on how to do this. My objective of the output is to have this get the student's quiz marks. What I have tried is to use an array to collect the quiz scores of the students and find the total average of all of them. The problem that I am having with the implementation of gathering the quiz marks is that the array always gives me error and red lines and saying that there is not existing class even though I have functions in the main file.
This is the code for the encapsulated functions:
public class Student {
// instance fields
private String firsName;
private String surName;
private long studentNumber;
}
//constuctors
public Student(String firstName, String surName, long studentNumber){
}
//accessors and mutator methods
//set student's name and surname. Changing student's name does not affect the students's loginId
public void setName(String firstName, String surName){
}
//returns name and surname separated by comma (name, surname)
public String getName(){
return firsName + ", " + surName;
}
public long getStudentNumber(){
return studentNumber;
}
public String getLoginId(){
return firsName.charAt(0) + surName.substring(0,4) + studentNumber % 100;
}
public String getInfo(){
return firsName + ", " + surName + "( " + getLoginId() + ", " + getStudentNumber() + ")";
}
public void setAddress(String number, String street, String city, String province, String postalCode){
}
public String getAddress(){
String address = getAddress();
return address;
}
//add a quiz score to the student
public void addQuiz(double quiz){
double [] quizMarks;
quizMarks = new double[]{ };
}
public double getQuizAverage(){
}
public String toString(){
}
This is the code for the test cases AKA the main file:
class StudentTester{
public static void main(String[] args){
// test Student constructor
Student student = new Student("Marry","jones",10000001);
System.out.println(student);
// test Student getName, getStudentNumber(), getLoginId()
System.out.println(student.getName());
System.out.println(student.getStudentNumber());
System.out.println(student.getLoginId());
// test Student getInfo()
System.out.println(student.getInfo());
// test Student addQuiz and getAverage
student.addQuiz(6.0);
student.addQuiz(8.5);
student.addQuiz(9.8);
System.out.println(student.getQuizAverage());
// add your test cases:
}
}