En el metodo precioFinal() intento que del que sea X caso me regrese el resultado de la suma del preciof
Codigo:
public class Electrodomestico{
public int preciobase;
public String color;
public char consumo;
public int peso;
public Electrodomestico(){
this.preciobase = 1000;
this.color = "blanco";
this.consumo = 'F';
this.peso = 5;
}
public Electrodomestico(int preciobase, int peso){
this.preciobase = preciobase; //$1000
this.color = "blanco";
this.consumo = 'F';
this.peso = peso; // 5 kg
}
public Electrodomestico(int preciobase, String color, char consumo, int peso){
this.preciobase = preciobase; //$1000
this.color = color; //blanco
this.consumo = consumo; //F
this.peso = peso; // 5kg
}
//Metodos
public void comprobarConsumoEnergetico(char letra){
switch(letra){
case 'A':
System.out.println("A");
break;
case 'B' :
System.out.println("B");
break;
case 'C' :
System.out.println("C");
break;
case 'D' :
System.out.println("D");
break;
case 'E' :
System.out.println("E");
break;
case 'F' :
System.out.println("F");
break;
default:
System.out.println("F");
}
}
public void comprobarColor(String color){
switch(color){
case "blanco":
System.out.println("");
break;
case "negro":
System.out.println("");
break;
case "rojo":
System.out.println("");
break;
case "azul":
System.out.println("");
break;
case "gris":
System.out.println("");
break;
default:
System.out.println("blanco");
}
}
public int precioFinal(){
int pesof;
if ((getPeso() >= 0) && (getPeso() <= 19)) {
pesof = System.out.println(getPreciobase() + 100);
}else if((getPeso() >= 20) && (getPeso() <= 49)) {
pesof = System.out.println(getPreciobase() + 500);
}else if ((getPeso() >= 50) && (getPeso() <= 79)) {
pesof = System.out.println(getPreciobase() + 800);
}else if (getPeso() > 80) {
pesof = System.out.println(getPreciobase() + 1000);
}
return pesof;
//System.out.println(comprobarConsumoEnergetico(getConsumo()));
System.out.println(getPeso());
System.out.println(getPreciobase());
}
//Getters y Setters
public void setPreciobase(int preciobase){
this.preciobase = preciobase;
}
public int getPreciobase(){
return preciobase;
}
public void setColor(String color){
this.color = color;
}
public String getColor(){
return color;
}
public void setConsumo(char consumo){
this.consumo = consumo;
}
public char getConsumo(){
return consumo;
}
public void setPeso(int peso){
this.peso = peso;
}
public int getPeso(){
return peso;
}
}
Error:
.\Electrodomestico.java:86: error: incompatible types: void cannot be converted to int
pesof = System.out.println(getPreciobase() + 100);
^
.\Electrodomestico.java:88: error: incompatible types: void cannot be converted to int
pesof = System.out.println(getPreciobase() + 500);
^
.\Electrodomestico.java:90: error: incompatible types: void cannot be converted to int
pesof = System.out.println(getPreciobase() + 800);
^
.\Electrodomestico.java:92: error: incompatible types: void cannot be converted to int
pesof = System.out.println(getPreciobase() + 1000);
^
4 errors