I am trying to work out what may be causing this problem for a while now. I am completely new to Java and BlueJ but have been looking at this for hours and cannot figure out what is causing the problem. Keep getting the error message "Incompatible types: Plasterer cannot be converted to Apprentice". Any help is greatly appreciated.
//Purpose of Program: To create a mixed array to hold 2 different Apprentice objects - Plasterer and Carpenter //Plasterer and Carpenter //All the details of each object are then displayed to the screen.
public class MixedLists
{
public static void main(String args[])
{
//Declaration of object list to hold 2 student objects
Apprentice [] apprenticeList = new Apprentice[2];
////////////////////////////////////////////////////////////////////
//Plasterer
//Taking in values
String NameIn, NumberIn, AddressIn, StudentIDIn, EmployerNameIn, FinalSem1GradeIn;
System.out.println("Entering data for Plasterer");
//Apprentice class attributes
System.out.print("\tEnter Name: ");
NameIn = EasyScanner.nextString();
System.out.print("\tEnter telephone number: ");
NumberIn = EasyScanner.nextString();
System.out.print("\tEnter Address: ");
AddressIn = EasyScanner.nextString();
System.out.print("\tEnter student id: ");
StudentIDIn = EasyScanner.nextString();
//Plasterer class attributes
System.out.print("\tEnter in Employer Name: ");
EmployerNameIn = EasyScanner.nextString();
System.out.print("\tEnter Final Semester 1 Grade: ");
FinalSem1GradeIn = EasyScanner.nextString();
//Initializing what is referenced by position 0 of the object list with a plasterer object
apprenticeList[0]=new Plasterer(NameIn, NumberIn, AddressIn, StudentIDIn, EmployerNameIn, FinalSem1GradeIn);
System.out.println("\n");
/////////////////////////////////////////////////////////////////
//Carpenter
String NameIn1,AddressIn1,Number1,StudentID1;
//additional variables
String awardSought,specialisation;
double gpaModuleGrade, industrialExperienceMark;
//Entering values for Carpenter
System.out.println("Entering data for Carpenter");
//Apprentice class attributes
System.out.print("\tEnter Name: ");
NameIn1 = EasyScanner.nextString();
System.out.print("\tEnter telephone number: ");
Number1 = EasyScanner.nextString();
System.out.print("\tEnter Address: ");
AddressIn1= EasyScanner.nextString();
System.out.print("\tEnter student id: ");
StudentID1= EasyScanner.nextString();
//Carpenter class attributes
System.out.print("\tEnter award sought: ");
awardSought = EasyScanner.nextString();
System.out.print("\tEnter specialist area: ");
specialisation = EasyScanner.nextString();
//Carpenter class attributes
System.out.print("\tEnter GPA Module Grade: ");
gpaModuleGrade = EasyScanner.nextString();
System.out.print("\tEnter industrial experience Grade: ");
industrialExperienceMark = EasyScanner.nextString();
//Initializing what is referenced by position 1 of the object list with a Carpenter object
apprenticeList[1]=new Carpenter(NameIn1, AddressIn1, Number1, StudentID1,awardSought,specialisation, gpaModuleGrade,industrialExperienceMark);
System.out.println("\n");
////////////////////////////////////////////////////////////////////
//for loop to display out contents of mixed object array
//Display out all information associated with Carpenter, Carpenter and CabinetMaker
System.out.println("Award Details for all Apprentices in the System\n");
for(int i = 0; i < apprenticeList.length; i++)
{
System.out.println(apprenticeList[i].printAwardDetails());
}
}
}
The Apprentice Class goes as such
public abstract class Apprentice
{
//attributes
private String Name;
private String Number;
private String Address;
private String StudentID;
public Apprentice (String NameIn, String NumberIn, String AddressIn, String StudentIDIn)
{
Name = NameIn;
Number = NumberIn;
Address = AddressIn;
StudentID = StudentIDIn;
}
//Methods to read the attributes
public String getName()
{
return Name;
}
public String getNumber()
{
return Number;
}
public String getAddress()
{
return Address;
}
public String getStudentID ()
{
return StudentID ;
}
public void setName(String NameIn)
{
Name = NameIn;
}
public void setNumber(String NumberIn)
{
Number = NumberIn;
}
public void setAddress(String AddressIn)
{
Address = AddressIn;
}
public void setStudentID (String StudentIDIn )
{
StudentID = StudentIDIn;
}
}