problems with asigning elements of an array to a constructor
I have created an array which holds data that is entered by a user using JOptionPane.
I would now like to create an object of a class called Module that was previously created. But the program says that the constructor module() cannot be found. Can somebody help because I need that object to be declared so that I can display the data that is entered by the user with the use of System.out.print(). Below is the code for the Module class:
public class Module
{
int level, finalMark ;
String moduleCode ;
Module(String mc, int l, int fm)
{
moduleCode = mc;
level = l;
finalMark = fm;
}
public String toString()
{
return level + " " + moduleCode + " " + finalMark ;
}
} // end class Module
Now this is the start of the code for class ModuleTest, where I am stuck. Like explained before, all I need is for the details entered by the user to be stored in an object in order to then display them:
import javax.swing.* ;
public class ModuleTest
{
public static void main ( String [] args )
{
int size ;
size = 3 ;
int level=0 ;
int finalMark ;
String moduleCode ;
String levelStr ;
String finalMarkStr ;
Module [] moduleInfo;
moduleInfo = new Module[size] ;
System.out.printf( "%s %8s %8s\n", "Level" , "ModuleCode", "FinalMark" ) ;
System.out.println( "------------------------------" ) ;
for (int i = 0 ; i < (moduleInfo.length - 1) ; i++ )
{
levelStr = JOptionPane.showInputDialog( "Please enter level: " ) ;
moduleCode = JOptionPane.showInputDialog( "Please enter module code: " ) ;
finalMarkStr = JOptionPane.showInputDialog( "Please enter final mark: " ) ;
// the string values that are entered have to be converted into integer
level = Integer.parseInt(levelStr) ;
finalMark = Integer.parseInt(finalMarkStr) ;
// create new object
Module m1 = new Module() ;
}
}