-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCafe.java
More file actions
57 lines (51 loc) · 1.5 KB
/
Copy pathCafe.java
File metadata and controls
57 lines (51 loc) · 1.5 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Andres
*/
public class Cafe {
int consecutivo;
double valor;
boolean molido;
Arabigo arabigo;
Robusta robusta;
String es;
public Cafe(String[] datos) {
this.molido = Boolean.parseBoolean(datos[4]);
this.consecutivo = Integer.parseInt(datos[2]);
this.valor = Double.valueOf(datos[3]);
es = datos[1];
if (!es.equals("Arabigo")) {
robusta = new Robusta(Double.valueOf(datos[5]));
} else {
arabigo = new Arabigo(datos[5], datos[6]);
}
}
@Override
public String toString() {
String molOrGra;
if(this.molido){
molOrGra = "Molido";
}
else{
molOrGra = "Grano";
}
if (!es.equals("Arabigo")) {
System.out.println("\t >Cafe Robusta");
return "\t Consecutivo: " + consecutivo
+ "\n \t Precio: $" + valor
+ "\n \t Presentacion: " + molOrGra
+ robusta.toString();
} else {
System.out.println("\t >Cafe Arabigo");
return "\t Consecutivo: " + consecutivo
+ "\n \t Precio: $" + valor
+ "\n \t Presentacion: " + molOrGra
+ arabigo.toString();
}
}
}