-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamion.java
More file actions
58 lines (37 loc) · 1.32 KB
/
Camion.java
File metadata and controls
58 lines (37 loc) · 1.32 KB
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
import java.util.Scanner;
public class Camion extends Vehiculo {
public Camion(String matricula) {
super(matricula);
}
public boolean pasaInspeccion(double NivelGases){
return NivelGases<4;
}
public static void main (String[] args) {
Camion Camiones[]=new Camion[5];
Camion T1= new Camion("6438-KLV");
Camion T2= new Camion("3794-HDI");
Camion T3= new Camion("9203-DJE");
Camion T4= new Camion("3023-SKO");
Camion T5= new Camion("4203-DEW");
for(int i=0; i<Camiones.length; i++) {
if(Camiones[i].equals(Camiones[4].getMatricula())) {
System.out.println("Vehiculos: " + Camiones[i] + " y " + Camiones[4]
+ " son iguales");
}
else if(!Camiones[i].equals(Camiones[4].getMatricula())) {
System.out.println("Vehiculos: " + Camiones[i] + " y " + Camiones[4]
+ " son distintos");
}
}
java.util.Scanner scan = new java.util.Scanner(System.in);
System.out.println("Matricula del coche que quiere localizar: ");
String matricula = scan.nextLine();
scan.close();
boolean localizado = true;
for(int i=0; i<Camiones.length && localizado; i++){
localizado = Camiones[i].equals(matricula);
System.out.println((localizado?"Si":"No")
+ "localizado el Camion con matricula " + matricula);
}
}
}