I'm working in CodeHS, and I get this error: constructor Jeans in class Jeans cannot be applied to given types;
I've looked, but I can't find how to solve this issue.
I've tried using just one of the parameters from the superclass, then all of them, then all plus one I created. The jeans have to be the color blue, hence why I'm trying to just call size.
Here's the super class:
public class Clothing
{
public String size;
public String color;
public Clothing(String size, String color)
{
this.size = size;
this.color = color;
}
public String getSize()
{
return size;
}
public String getColor()
{
return color;
}
public String toString()
{
return "Clothing with size " + size + " and the color " + color;
}
}
Here's the Jeans class:
public class Jeans extends Clothing
{
public Jeans(String size)
{
super(size);
}
public String toString()
{
return "Blue jeans with size " + size;
}
}
Here's the coding I'm testing:
public class ClothingTester extends ConsoleProgram
{
public void run()
{
Clothing myClothes = new Clothing("24", "grey");
System.out.println(myClothes);
Sweatshirt mySweatshirt = new Sweatshirt("24", "grey", true);
System.out.println(mySweatshirt.getSize());
TShirt myTShirt = new TShirt("24", "grey", "polyester");
System.out.println(myTShirt);
Jeans myJeans = new Jeans("24");
System.out.println(myJeans);
}
}
Here's two other subclasses I had to use super class Clothing for(these work fine):
public class TShirt extends Clothing
{
public String fabric;
public TShirt(String size, String color, String fabric)
{
super(size, color);
this.fabric = fabric;
}
public String getFabric()
{
return fabric;
}
public String toString()
{
return "T-shirt with size " + size + " and is the color " + color + " and is made of " + fabric;
}
}
public class Sweatshirt extends Clothing
{
public boolean hasHood;
public Sweatshirt(String size, String color, boolean hasHood)
{
super(size, color);
this.hasHood = hasHood;
}
public boolean hasHood()
{
return hasHood;
}
public String toString()
{
return "Sweatshirt with size " + size + " and is the color " + color + ". Does it have a hood? " + hasHood;
}
}
I expect Jeans to output the size (the color should stay blue), but I get a compiler time error.