mardi 6 janvier 2015

I am having troubles writing a test driver

my first time reaching out for help to solve a question, not sure what is causing the issue. I have these two classes I wrote, and the assignment asks me to make a test driver proving that the classes work.


Student Class:



public class Student{
private Course[] courseList;
private static int numCourses;
private final int maxCourses;

public Student(int max){
maxCourses = max;
courseList = new Course[numCourses];
numCourses = 0;
}
// part 1, done
public boolean addCourse(Course newClass){
boolean success = false;

for(int i=0; i<=maxCourses; i++){

if(i == numCourses){
courseList[i] = newClass;
success = true;
numCourses++;
}
}
return success;
}
// part 2, done
public boolean dropCourse(Course oldClass){
boolean success = false;

for(int i=0; i<=courseList.length; i++){
if (courseList[i] == oldClass){
courseList[i] = null;
numCourses--;
success = true;
}
}
return success;
}
// part 3, done.
public int getNumCourses(){
return numCourses;
}
//part 4, done
public boolean isFullTime(){
boolean success = false;
if (numCourses >= 3){
success = true;
}
return success;
}
// part 5, done
public String getClassList(){
String list = "";

for(int i=0;i<=numCourses; i++){
list = courseList[i].getID() + "\t" + courseList[i].getName() + "\n";

}
return list;
}
}


and a Course class:



public class Student{
private Course[] courseList;
private static int numCourses;
private final int maxCourses;

public Student(int max){
maxCourses = max;
courseList = new Course[numCourses];
numCourses = 0;
}
// part 1, done
public boolean addCourse(Course newClass){
boolean success = false;

for(int i=0; i<=maxCourses; i++){

if(i == numCourses){
courseList[i] = newClass;
success = true;
numCourses++;
}
}
return success;
}
// part 2, done
public boolean dropCourse(Course oldClass){
boolean success = false;

for(int i=0; i<=courseList.length; i++){
if (courseList[i] == oldClass){
courseList[i] = null;
numCourses--;
success = true;
}
}
return success;
}
// part 3, done.
public int getNumCourses(){
return numCourses;
}
//part 4, done
public boolean isFullTime(){
boolean success = false;
if (numCourses >= 3){
success = true;
}
return success;
}
// part 5, done
public String getClassList(){
String list = "";

for(int i=0;i<=numCourses; i++){
list = courseList[i].getID() + "\t" + courseList[i].getName() + "\n";

}
return list;
}
}


For some reason if I make a test driver even one as simple as:



public class tester{

public static void main(String[] args){
Course one = new Course(Java);
}
}


I receive an error at my parameter saying cannot find symbol



javac tester.java
tester.java:6: error: cannot find symbol
one = new Course(name);
^
symbol: variable name
location: class tester
1 error


I had a much longer test driver but it did not make it past the first few lines as this was the same error just several of the same error.


Thanks for your time.


Aucun commentaire:

Enregistrer un commentaire