- #1
redskins21
- 1
- 0
Hello,
I am trying to figure out what I did wrong and I couldn't figure it out.
here is the error code:
setMake(java.lang.String) in Automobile cannot be applied to ().
Class file:
import java.util.Scanner;
public class Automobile
{
private int num; //number of automobiles to describe
private String make; //make of automobile
private String color; //color of automobile
public void setIteration()
{
Scanner stdIn = new Scanner(System.in);
System.out.print("How many cars do you want to consider: ");
this.num = stdIn.nextInt();
this.make = setMake("body");
this.color = setColor("paint");
}//end constructor
public void printColor()
{
System.out.println(this.color);
}
public void printMake()
{
System.out.println(this.make);
}
private String setMake(String makeType)
{
Scanner stdIn = new Scanner(System.in);
String make;
do
{
System.out.print("Select Buick, Chevrolet, or Pontiac (b,c,p): ");
make = stdIn.nextLine();
if (make.charAt(0) != 'b' || make.charAt(0) != 'g' || make.charAt(0) != 'p');
else
System.out.print("The only valid selections are 'b', 'c', or 'p'");
} while (!make.equals("b") && !make.equals("c") && !make.equals("p"));
switch (make.charAt(0))
{
case 'b':
make = "Buick";
break;
case 'c':
make = "Chevrolet";
break;
case 'p':
make = "Pontiac";
}//end switch
return make;
}//end setMake
private String setColor(String colorType)
{
Scanner stdIn = new Scanner(System.in);
String color;
do
{
System.out.print("Select Blue, Green, or Red(b,g,r): ");
color = stdIn.nextLine();
if (make.charAt(0) != 'b' || make.charAt(0) != 'g' || make.charAt(0) != 'r');
else
System.out.print("The only valid selections are 'b', 'c', or 'r'");
} while (!make.equals("b") && !make.equals("g") && !make.equals("r")) ;
switch (make.charAt(0))
{
case 'b':
make = "Blue";
break;
case 'g':
make = "Green";
break;
case 'r':
make = "Red";
}//end switch
return color;
}//end setColor
}//end class Automobile
Driver Class:
import java.util.Scanner;
public class AutomobileDriver
{
public static void main(String[] args)
{
Automobile car = new Automobile();
car.setIteration();
car.setMake();
car.setColor();
car.printColor();
car.printMake();
}//end main
}//end driverClass
SAMPLE DISPLAY:
How many cars do you want to consider? 2
Select Buick, Chevrolet, or Pontiac (b,c,p): x
The only valid selections are 'b', 'c', or 'p'
Select Buick, Chevrolet, or Pontiac (b,c,p): p
Select blue, green, or red (b,g,r): r
red Pontiac
Select Buick, Chevrolet, or Pontiac (b,c,p): c
Select blue, green, or red (b,g,r): g
green Chevrolet
THANKS!
I am trying to figure out what I did wrong and I couldn't figure it out.
here is the error code:
setMake(java.lang.String) in Automobile cannot be applied to ().
Class file:
import java.util.Scanner;
public class Automobile
{
private int num; //number of automobiles to describe
private String make; //make of automobile
private String color; //color of automobile
public void setIteration()
{
Scanner stdIn = new Scanner(System.in);
System.out.print("How many cars do you want to consider: ");
this.num = stdIn.nextInt();
this.make = setMake("body");
this.color = setColor("paint");
}//end constructor
public void printColor()
{
System.out.println(this.color);
}
public void printMake()
{
System.out.println(this.make);
}
private String setMake(String makeType)
{
Scanner stdIn = new Scanner(System.in);
String make;
do
{
System.out.print("Select Buick, Chevrolet, or Pontiac (b,c,p): ");
make = stdIn.nextLine();
if (make.charAt(0) != 'b' || make.charAt(0) != 'g' || make.charAt(0) != 'p');
else
System.out.print("The only valid selections are 'b', 'c', or 'p'");
} while (!make.equals("b") && !make.equals("c") && !make.equals("p"));
switch (make.charAt(0))
{
case 'b':
make = "Buick";
break;
case 'c':
make = "Chevrolet";
break;
case 'p':
make = "Pontiac";
}//end switch
return make;
}//end setMake
private String setColor(String colorType)
{
Scanner stdIn = new Scanner(System.in);
String color;
do
{
System.out.print("Select Blue, Green, or Red(b,g,r): ");
color = stdIn.nextLine();
if (make.charAt(0) != 'b' || make.charAt(0) != 'g' || make.charAt(0) != 'r');
else
System.out.print("The only valid selections are 'b', 'c', or 'r'");
} while (!make.equals("b") && !make.equals("g") && !make.equals("r")) ;
switch (make.charAt(0))
{
case 'b':
make = "Blue";
break;
case 'g':
make = "Green";
break;
case 'r':
make = "Red";
}//end switch
return color;
}//end setColor
}//end class Automobile
Driver Class:
import java.util.Scanner;
public class AutomobileDriver
{
public static void main(String[] args)
{
Automobile car = new Automobile();
car.setIteration();
car.setMake();
car.setColor();
car.printColor();
car.printMake();
}//end main
}//end driverClass
SAMPLE DISPLAY:
How many cars do you want to consider? 2
Select Buick, Chevrolet, or Pontiac (b,c,p): x
The only valid selections are 'b', 'c', or 'p'
Select Buick, Chevrolet, or Pontiac (b,c,p): p
Select blue, green, or red (b,g,r): r
red Pontiac
Select Buick, Chevrolet, or Pontiac (b,c,p): c
Select blue, green, or red (b,g,r): g
green Chevrolet
THANKS!