I have this assignment for my java class, it runs fine, but the professor wants us to incorporate a private gradeExam method, which I don't know how it work fit, since I cannot call it from the DriverTest class which contains my main.
package project6;
/* A demonstration of how to Create Classes and Arrays and Test them.
* Javier Falcon
* Cop2250-U04 Project6
* #5 on page 529 of the textbook
*
*/
public class DriverExam {
private char [] correct = {'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A',
'C', 'D','B', 'C', 'D', 'A', 'D', 'C',
'C', 'B', 'D', 'A'};
private char [] student;
private int [] missed;
private int numCorrect = 0;
private int numIncorrect = 0;
/*
* Constructor fills student with content in s
*
* @param s char array filled with student answers
*
*/
public DriverExam(char[] s)
{
student = s;
}
/**
* This method makes sure the paper is graded.
*
* @param
* @return
*/
private void gradeExam()
{
totalCorrect();
totalIncorrect();
passed();
questionsMissed();
}
/**
* This method creates the array for the missed questions.
*
* @param
* @return
*/
private void makeMissedArray()
{
int[] missed = {};
}
/**
* This method determines whether you pass or fail.
*
* @param
* @return boolean which decides pass or fail
*/
public boolean passed()
{
return (totalCorrect() > 14);
}
/**
* This method calculates the number of correct answers.
*
* @param
* @return number of correct answers
*/
public int totalCorrect()
{
int sameAnswers = 0;
for (int i = 0; i < correct.length; i++)
{
if (student[i] == correct[i])
{
sameAnswers++;
}
}
return sameAnswers;
}
/**
* This method calculates and returns number of wrong.
*
* @param
* @return number of incorrect answers
*/
public int totalIncorrect()
{
int missedAnswers = 0;
missedAnswers = correct.length - totalCorrect();
return missedAnswers;
}
/**
* This method determines which spots in the student array were
* incorrect.
*
* @param
* @return array with numerical values of those missed
*/
public int[] questionsMissed()
{
int size = correct.length - totalCorrect();
makeMissedArray();
if (size < 1)
return missed;
else
missed = new int [size];
int pos = 0;
for (int i = 0; i < correct.length; i++)
{
if (correct[i] != student[i])
{
missed[pos] = (i + 1);
pos = pos + 1;
}
}
return missed;
}
}