I'm currently working on a very simple script and I'm getting an error that doesn't pop up in the example provided. I have a set of code and a client to test it. I'm getting this error when I try to run the code. I get this for all three instances where I try to use "new Class" in the client.
ClassClient.java:5: error: constructor Class in class Class cannot be applied to given types;
Class code = new Class("1234");
^
required: String,String,String
found: String
reason: actual and formal argument lists differ in length
Here is the first set of code:
public class Class
{
//attributes
public String code;
private String name;
private String credit;
//constructor
public Class(String newCode, String newName, String newCredit)
{
setCode(newCode);
setName(newName);
setCredit(newCredit);
}
//get|sets
public String getCode()
{
return code;
}
public void setCode(String newCode)
{
code = newCode;
}
public String getName()
{
return name;
}
public void setName(String newName)
{
name = newName;
}
public String getCredit()
{
return credit;
}
public void setCredit(String newCredit)
{
credit = newCredit;
}
public String toString()
{
return ("The code for this class is: "+code + "\n" + "The name for this class is :"+name + "\n" + "The number of credits this course has is :"+credit);
}
public boolean equals(Object o)
{
if(!(o instanceof Class))
return false;
else
{
Class x = (Class) o;
Class y = (Class) o;
Class z = (Class) o;
return(code.equals(x.code) || name.equals(y.name) || credit.equals(z.credit));
}
}//endelse
}//end class
And here is the client that tests the code:
public class ClassClient
{
public static void main(String [] args)
{
Class code = new Class("1234");
Class name = new Class("Java");
Class credit = new Class("4");
System.out.println("The code for this class is: "+code + "\n" + "The name for this class is :"+name + "\n" + "The number of credits this course has is :"+credit);
}
}