No entiendo porque me marca error
Publicado por Monse (2 intervenciones) el 12/05/2013 01:26:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package polimorfism;
import java.util.Scanner;
class polimorfis{
public static void main(String[]args){
Empleado juan= new lavador("lavador","juan",20,2,5,5);
System.out.println("la clave es :"+juan.getclave());
System.out.println("el nombre es:"+juan.getnombre());
System.out.println("la edad es:"+juan.getedad());
System.out.println("el sexo es:"+juan.getsexo());
System.out.println("la antiguedad es:"+juan.getantiguedad());
juan.CapturarDatos();
}
abstract class Empleado {
protected Scanner teclado;
protected String clave;
protected String nombre;
protected int edad;
protected int sexo;
protected int antiguedad;
public void setclave(String cl) { clave=cl;}
public void setnombre(String no){nombre=no;}
public void setedad(int ed) { edad=ed;}
public void setsexo(int se){sexo=se;}
public void setantiguedad(int ant){antiguedad=ant;}
public String getclave () {return clave;}
public String getnombre() {return nombre;}
public int getedad () {return edad;}
public int getsexo() {return sexo;}
public int getantiguedad() {return antiguedad;}
public Empleado(String cl,String no,int ed,int se,int ant)
{clave=cl; nombre=no;edad=ed;sexo=se; antiguedad=ant;}
public abstract double Sueldo ();
public void CapturarDatos(){
teclado=new Scanner(System.in);
System.out.print("Ingrese clave:");
clave=teclado.next();
System.out.print("Ingrese nombre:");
nombre=teclado.next();
System.out.print("Ingrese edad:");
edad=teclado.nextInt();
System.out.print("Ingrese 1 si es femenino o 2 si es masculino:");
sexo=teclado.nextInt();
System.out.print("Ingrese antiguedad en años en la empresa:");
antiguedad=teclado.nextInt();
}
public int CalcularPrima(){
return (antiguedad*100);
}
public String Sexo(){
String S;
if (sexo==1){
S= "Femenino";}
else
S="Masculino";
return S;
}
public int CalcularBono(){
int bono;
if (sexo==1){
bono= 100;}
else
bono=50;
return bono;
}
public void imprimir1(){
System.out.println ("clave:"+clave);
System.out.println ("nombre:"+nombre);
System.out.println ("edad:"+edad);
System.out.println ("sexo:"+Sexo());
System.out.println ("antiguedad:"+antiguedad);
System.out.println ("sueldo fijo $500.00");
System.out.println ("prima:"+ CalcularPrima());
System.out.println ("bono por sexo:"+ CalcularBono());
}
class lavador extends Empleado{
protected int Cchico;
protected int Ccgrande;
public void setCchico (int ch) {Cchico=ch;}
public void setCcgrande (int g) {Ccgrande=g;}
public int getCchico(){return Cchico;}
public int getCcgrande(){return Ccgrande;}
public void CapturarDatos(){
teclado=new Scanner(System.in);
System.out.print("Cantidad de coches chicos lavados:");
Cchico=teclado.nextInt();
System.out.print("Cantidad de coches chicos lavados:");
Ccgrande=teclado.nextInt();
}
lavador (String cl,String no, int ed, int se, int ant, int ch, int g)
{
super (cl,no,ed,se,ant);
Cchico=ch;
Ccgrande=g;
}
public double Sueldo(){return (CalcularPrima()+CalcularBono()+(Cchico*10)+(Ccgrande*20)+(300));}
}
}
}
Valora esta pregunta


0