-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProducto.java
More file actions
81 lines (60 loc) · 1.43 KB
/
Producto.java
File metadata and controls
81 lines (60 loc) · 1.43 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package robot.robonce;
/*
* Clase: Producto.
* Descripción: Producto del supermercado.
* Autor: Miguel Ruiz Nogués.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import lejos.nxt.LightSensor;
/*
* Clase: Producto.
* Descripción: Producto del supermercado.
* Autor: Miguel Ruiz Nogués.
*/
public class Producto {
//Atributos:
private int clave_producto;
private int color;
private String nombre;
//Lectura por Teclado:
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String linea;
//Light Sensor:
LightSensor light;
//Constructor
public Producto(int clave, String nombre, LightSensor lightproducto){
this.clave_producto=clave;
this.nombre=nombre;
light = lightproducto;
color=obtener_color();
}
//Métodos:
/*
* OBTENER COLOR
* Asocia el color medido con el producto.
*/
public int obtener_color (){
System.out.println("Producto "+nombre+". Situe el sensor en el color deseado y pulse enter...");
try{
linea = br.readLine();
}
catch(Exception e){
e.printStackTrace();
}
int valor = light.readValue();
System.out.println("COLOR: "+valor);
return valor;
}
public int get_Clave()
{
return clave_producto;
}
public int get_Color ()
{
return color;
}
public String get_Nombre (){
return nombre;
}
}