I'm doing the code for a shop and this part is to allow the staff to add a phone to existing stock. I cant figure out what the problem is as it wont compile and says "incompatible types", it marks the part [ name= " "; type=" "; colour=" ";]
Here's the part of the driver class that it is in:
//add new phone to stock
public void addPhone( ) {
Phone phone = new Phone ( itemsId, brand, price, name, type, colour);
Scanner scan = new Scanner(System.in);
String itemsId;
String brand;
double price;
String name;
String type;
String colour;
for (int counter=0; counter< 1; counter ++)
{
itemsId= " ";
brand=" ";
price=
name= " ";
type=" ";
colour=" ";
System.out.println("Enter itemsID: ");
itemsId= scan.nextLine();
System.out.println("Enter brand: ");
brand= scan.nextLine();
System.out.println("Enter price: ");
price= scan.nextdouble();
System.out.println("Enter name: ");
name= scan.nextLine();
System.out.println("Enter type: ");
type= scan.nextLine();
System.out.println("Enter colour: ");
colour= scan.nextLine();
}
phoneList.add(phone);
}
price=price=name=" ", so you are trying to assign a string to a double.price = 5.0;or whatever.