Java do-while conditions is not working

Hello everyone,

I have a main class (maincoche.java) where I have asking to introduce some values using JOptionPane method.
In the second class(coche.java), I use the value entered to provide an answer.
So, in the main class maincoche.java I use JOptionPane to introduce an String value

The answer should be si or SI or Si, etc (yes). This value is sent to a SETTER in a second class, the setter name is config_seats(String asientos_cuero) which receive teh string value

Here is the method:

mifurgoneta.config_seats(JOptionPane.showInputDialog(“Tiene asientos de cuero”));
System.out.println(mifurgoneta.get_asientos());

here is my setter

public void config_seats(String asientos_cuero)
{

		//do{

			if (asientos_cuero.equalsIgnoreCase("si") ||  asientos_cuero.equalsIgnoreCase("s"))
		{
			this.asientos_cuero = true;
		}
	
	
		else
		{
			this.asientos_cuero = false;
		}
	
	//}while(!asientos_cuero.equalsIgnoreCase("si") ||  !asientos_cuero.equalsIgnoreCase("s"));
}

So my question is:
How can I use a do-while in order to repeat the code if I introduce a wrong value different to (si or SI or Si)?
The condition IF only handles the case sensitive for the anwer “si” but I think I need do - while in case I introduce any other character like wrong character “sdjdjsdh” or numbers “17261” or cancel.

Then, when I use the do-while the program doesn’t print the value and keep runing without any action. It is like I can not validate something coming from another class

Here you have the complete code

main class
package poo;

import javax.swing.*;

public class maincoche {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	
	//sintaxis   clase + name_oF_object + new constructor
	coche micoche1 =  new coche();
	
	micoche1.establece_color("Rojo");
	
	
	//sintaxis   clase + name_oF_object + new constructor
	furgoneta mifurgoneta = new furgoneta(7,1000);
	
	
	mifurgoneta.establece_color(JOptionPane.showInputDialog("Cual es el color :"));
	System.out.println(mifurgoneta.dime_color());
	
	mifurgoneta.config_seats(JOptionPane.showInputDialog("Tiene asientos de cuero"));
	System.out.println(mifurgoneta.get_asientos());
	
	
	
	
	
	
	
	/*
	coche micoche = new coche();
	
	
	micoche.establece_color(JOptionPane.showInputDialog("Introduce color")); 
	
	System.out.println(micoche.provide_generaldata());
	
	
	System.out.println(micoche.dime_color());
	
	

	
	
	

	micoche.config_seats(JOptionPane.showInputDialog("Tiene asientos de cuero?"));
	
	System.out.println(micoche.get_asientos());
	
	
	micoche.conf_climatizador(JOptionPane.showInputDialog("Tiene climatizador?"));
	System.out.println(micoche.get_climatizador());
	
	
	*/
	
	
	
	
	


}

}

second class
package poo;

public class coche {

//the key private encapsula las propiedades para que no sean modificadas desde otra calse
private int ruedas;
private int largo;
private int ancho;
private int motor;
private int peso_plataforma;

private String color1;



private String color;
private int peso_total;
boolean asientos_cuero, climatizador;



//constructor
public coche()
{
	ruedas=4;
	largo=2000;
	ancho=300;
	motor=1600;
	peso_plataforma=500;
}

//metodo getter obtain value propertie  
//sintaxis es Public + tipodedato + nameofmethod() + usa return
public String  provide_generaldata()
{
	
	
	return "El coche tiene: " + ruedas + " ruedas" + " Con un largo de " + largo/1000 + 
			" metros " + " y peso de " + peso_plataforma + " kg";
	
}

//**************************************
//method setter
public void set_color()
{
	color1= "rojo";
}

//method getter
public String provide_color()
{
	return "El color is: " + color1;
}
//******************************8

//setters modifica valor propiedades
//sintaxis public+void+nombre_method no  usa return

public void establece_color(String color_coche)
{
	color=color_coche;
	
}

//method getter
public String dime_color()
{
	return "El color del coche es : " + color;
}



//setter
public void config_seats(String asientos_cuero)
{
	
	
		//do{

			if (asientos_cuero.equalsIgnoreCase("si") ||  asientos_cuero.equalsIgnoreCase("s"))
		{
			this.asientos_cuero = true;
		}
	
	
		else
		{
			this.asientos_cuero = false;
		}
	
	//}while(!asientos_cuero.equalsIgnoreCase("si") ||  !asientos_cuero.equalsIgnoreCase("s"));
}

//getter
public String get_asientos()
{
	if(asientos_cuero==true) {
		
		return "el coche tiene asientos de cuero";
	}
	else {
		return "no tiene cuero";
	}
}


public void conf_climatizador(String climatizador) {
	
	if(climatizador.equalsIgnoreCase("si") || climatizador.equalsIgnoreCase("s"))
	{
		this.climatizador = true;
	}
	else
	{
		this.climatizador = false;
	}
}


public String get_climatizador()
{
	if(climatizador==true) {
		
		return "el coche tiene climatizador";
	}
	else
	{
		return "no tiene climatizador";
	}
}

}
I am really appreciate your support

Regards

Jose

I think there will be a semi colon after while

Hi
thanks for your update. There is a semicolon. Without it, the compiler giev an error
I am opened for another idea :slight_smile: