I have a class CollegeCourse:
public class CollegeCourse { private String courseId; private int creditHours; private char grade; public CollegeCourse(String i, int h, char g) { this.courseId = i; this.creditHours = h; this.grade = g; } public String courseId(){return this.courseId;} public int creditHours(){return this.creditHours;} public char grade(){return this.grade;} public void setcourseId(String i){this.courseId = i;} public void setcreditHours(int h){this.creditHours = h;} public void setgrade(char g){this.grade = g;} }
Then I have the second class Student:
public class Student { private int studentId; private CollegeCourse[] courseArray = new CollegeCourse[5]; public Student(int s, CollegeCourse[] c) { this.studentId = s; this.courseArray = c; } public int studentId(){return this.studentId;} public CollegeCourse[] courseArray(){return this.courseArray;} public void setstudentId(int s){this.studentId = s;} public void setcourseArray(CollegeCourse[] c){this.courseArray = c;} }
In my tester class I am trying to instantiate the Student class like:
Student stu = new Student();
The compiler complains:
InputGrades.java:8: error: constructor Student in class Student cannot be applied to given types; Student stu = new Student(12, new CollegeCourse("CSI 2010", 4, 'A')); ^
Also when I want to take input can I use a setter like this?:
stu.courseId = console.next();