Java - Una Pizzeria en Java,Eclipse

 
Vista:

Una Pizzeria en Java,Eclipse

Publicado por the cupcake (1 intervención) el 03/04/2019 22:45:12
holaa, veran e hecho todo mi codigo ahora solo tengo el problema que no tengo ni idea de como hacer que se vendan las pizzas, tengo que aañadir un menu pòr categoria de carnes,quesos,salsas y vegetales...
son 3 clases las que tengo y no tengo ni idea de como hacer esa partye que les menciono.

les adjuntare las clase para ver si me pueden ayudar con este detalle...

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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
//CLASE 1 PROYECTO LA PRINCIPAL.
package hn.uth.proyecto;
 
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Scanner;
import java.util.stream.Stream;
 
public class Proyecto {
 
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner teclado = new Scanner(System.in);
		Inventario inventario = new Inventario();
		Ingredientes ingredientes = new Ingredientes();
		inventario.cargarInventario();
		System.out.println("\n\t\t\tBienvenido a Pizzopolis");
		System.out.println("\t\t***********************************");
		System.out.println("\t¡La vida es muy corta para comer pizzas de las malas!\n");
 
		int opcion2 = 0;
		int opcion=0;
 
 
		do {
			imprimirMenu();
			opcion = leerOpcionMenu();
			switch (opcion) {
 
			case 1:
 
					System.out.println("1. Agregar nuevo ingrediente");
					System.out.println("2. Eliminar ingrediente");
					System.out.println("3. Modicicar precio ");
					//System.out.println("4. Salir al menu principal");
					opcion2 = teclado.nextInt();
 
					switch (opcion2) {
 
					case 1:
 
						inventario = ingresarIngredientes(inventario);
 
						break;
					case 2:
						inventario = eliminarIngrediente(inventario);
						break;
					case 3:
						inventario  = modificarPrecio(inventario);
						break;
					default:
						break;
					}
 
 
				// FINALIZAR PASO1
				break;
 
			case 2:
				// CONSULTAR INFORMACION
 
				System.out.println("1. Por categorias");
				System.out.println("2. Por Precios");
				System.out.println("3. Por Ingredientes mas vendidios");
				int opcionConsu = teclado.nextInt();
 
				{
					if (opcionConsu == 1) {
						inventario.listarCategorias();
 
					} else if (opcionConsu == 2) {
						archivoPrecio();
					} else if (opcionConsu == 3) {
						archivoMasVendidos();
					}
 
				}
 
				break;
 
			case 3:
				// VENDER:
				System.out.println("1. Arma tu propia pizza");
				System.out
						.println("2. Elige una de nuestros combos de pizzas armadas");
				int opcionVender = teclado.nextInt();
				if (opcionVender == 1) {
					System.out
							.println("Seleccione la categoria que usted desea: ");
					System.out.println("1. Quesos");
					System.out.println("2. Salsas");
					System.out.println("3. Carnes");
					int opcionArmar = teclado.nextInt();
					if (opcionArmar == 1) {
						System.out.println("1. Chedar");
						int queso1 = 15;
						System.out.println("2. Azul");
						int queso2 = 19;
						System.out.println("3. Parmesano");
						int queso3 = 20;
 
						System.out.println("EL total a pagar es ");
 
					}
					System.out.println("");
					System.out.println();
				} else {
 
				}
 
			default:
				break;
			}
		} while (opcion != 4);
 
	}
 
	public static void imprimirMenu() {
		System.out.println("1. Administrar ingredeintes");
		System.out.println("2. Consultar información");
		System.out.println("3. Vender");
		System.out.println("4. Salir");
		System.out.println("\nIngrese la opcion deseada: ");
		System.out.println("--------------------------- ");
	}
 
	public static Inventario mostrarIngre(Inventario inventario) {
		inventario.listarIngredientes();
		return inventario;
	}
	public static Inventario modificarPrecio(Inventario inventario){
 
		inventario.mostrarPrecio();
		Scanner teclado = new Scanner(System.in);
		int opcion = teclado.nextInt();
		System.out.println("Ingrese el precio nuevo: ");
		double precioNuevo =  teclado.nextDouble();
		inventario.modificarPrecio(opcion, precioNuevo);
		return inventario;
	}
 
	public static Inventario eliminarIngrediente(Inventario inventario) {
		inventario.mostrarMenuIngredientes();
		Scanner teclado = new Scanner(System.in);
		int eliminar = teclado.nextInt();
		inventario.eliminarIngrediente(inventario.inventario.get(eliminar - 1));
		return inventario;
	}
 
	public static int leerOpcionMenu() {
		@SuppressWarnings("resource")
		Scanner teclado = new Scanner(System.in);
		return teclado.nextInt();
	}
 
	private static Inventario ingresarIngredientes(Inventario inventario) {
		Ingredientes ingreNuevo = new Ingredientes();
		String nombre = ingreNuevo.pedirNombre();
		String categoria = ingreNuevo.pedirCategoria();
		double precio = ingreNuevo.pedirPrecio();
 
		inventario.agregarIngrediente(nombre, categoria, precio);
		return inventario;
	}
 
	private static Inventario listarIngrediente(Inventario inventario) {
		inventario.listarIngredientes();
		return inventario;
 
	}
 
	private static void archivoCategoria2() {
		File archivo = new File("C:\\categoria.txt");
		if (archivo.exists()) {
			// ARCHIVO EXISTE
			try {
				Stream<String> lineas = Files.lines(archivo.toPath());
				System.out.println("");
				System.out.println("__________________________________");
				// AGREGAR UN LIST
				lineas.forEach(linea -> System.out.println(linea));
				System.out.println("__________________________________");
				System.out.println("");
				lineas.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			// ARCHIVO NO EXISTE
			System.out.println("El archivo NO existe :(");
		}
 
	}
 
	private static void archivoPrecio() {
 
		File archivo1 = new File("C:\\precio.txt");
 
		if (archivo1.exists()) {
			// ARCHIVO EXISTE
 
			try {
				Stream<String> lineas = Files.lines(archivo1.toPath());
 
				System.out.println("");
				System.out.println("__________________________________");
 
				lineas.forEach(linea -> System.out.println(linea));
 
				System.out.println("__________________________________");
				System.out.println("");
 
				lineas.close();
 
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
 
		} else {
			// ARCHIVO NO EXISTE
			System.out.println("El archivo NO existe :(");
		}
	}
 
	private static void archivoMasVendidos() {
		File archivo2 = new File("C:\\vendidos.txt");
		if (archivo2.exists()) {
			// ARCHIVO EXISTE
			try {
				Stream<String> lineas = Files.lines(archivo2.toPath());
				System.out.println("");
				System.out.println("__________________________________");
				lineas.forEach(linea -> System.out.println(linea));
				System.out.println("__________________________________");
				System.out.println("");
				lineas.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			// ARCHIVO NO EXISTE
			System.out.println("El archivo NO existe :(");
		}
	}
 
}

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
//CLASE 2 INVENTARIO.
package hn.uth.proyecto;
 
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Stream;
 
public class Inventario {
	public List<Ingredientes> inventario = new ArrayList<Ingredientes>();
 
	public List<String> categorias = new ArrayList<>();
 
	public void agregarIngrediente(String nombre, String categoria,
			double precio) {
		Ingredientes ingrediente1 = new Ingredientes();
		ingrediente1.agregarIngrediente(nombre, categoria, precio);
		inventario.add(ingrediente1);
	}
 
	public void eliminarIngrediente(Ingredientes ingre) {
		System.out.println("Ingrediente Eliminado.");
		ingre.imprimirIngrediente();
		inventario.remove(ingre);
	}
 
	public void listarIngredientes() {
		System.out.println("Imprimiendo listado de ingredientes disponibles: ");
		if (inventario.isEmpty()) {
			System.err.println("Inventario de ingrednientes está vacío.");
			System.out.println("");
		} else {
			inventario.forEach(toping -> toping.imprimirIngrediente());
		}
	}
 
	public void listarCategorias() {
		System.out.println("Imprimiendo listado de categorias disponibles: ");
		if (categorias.isEmpty()) {
			System.err.println("Inventario de categorias está vacío.");
			System.out.println("");
		} else {
			categorias.forEach(categoria -> System.out.println(categoria));
		}
	}
 
	public void guardarInventario() {
 
	}
	public void mostrarPrecio(){
		int indice = 1;
		for (Ingredientes ingrediente : inventario) {
			ingrediente.listarIngre(indice);
			indice++;
		}
	}
	public void modificarPrecio(int opcion, double precioNuevo ){
		//Menu
		//Seleccionar la opcoin
		//
		Ingredientes modificar = inventario.get(opcion-1);
		modificar.precio= precioNuevo;
		inventario.remove(modificar);
		inventario.add(modificar);
 
 
	}
	public void mostrarMenuIngredientes() {
		System.out.println("Seleccione el ingrediente que desea eleminar: ");
		if (inventario.isEmpty()) {
			System.err.println("No hay ingredientes en inventario");
		} else {
			int indice = 1;
			for (Ingredientes ingrediente : inventario) {
				ingrediente.listarIngre(indice);
				indice++;
			}
		}
	}
 
	public void cargarInventario() {
		File archivo = new File("C:\\Pizza\\categoria.txt");
		if (archivo.exists()) {
			// ARCHIVO EXISTE
			try {
				Stream<String> lineas = Files.lines(archivo.toPath());
				// AGREGAR UN LIST
				lineas.forEach(linea -> {
					// ARREGLO
					String[] valores = linea.split(",");
					categorias.add(valores[0]);
					agregarIngrediente(valores[1], valores[0],
							Double.parseDouble(valores[2]));
 
				});
				lineas.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			// ARCHIVO NO EXISTE
			System.out.println("El archivo NO existe :(");
		}
 
	}
}

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
//CLASE 3 INGREDIENTES.
package hn.uth.proyecto;
 
import java.util.Scanner;
 
public class Ingredientes {
	public String nombre = "";
	public String categoria = "";
	public double precio = 0;
 
	public void agregarIngrediente(String nombreIn, String categoriaIn, double precioIn) {
		nombre = nombreIn;
		categoria = categoriaIn;
		precio = precioIn;
	}
	public void imprimirCategoria() {
		System.out.println("Ingredientes de la categoria: "+categoria);
		System.out.println("----------------------------------");
		System.out.println("nombre: "+nombre);
		System.out.println("Precio: Lps."+precio);
		System.out.println("----------------------------------");
	}
	public void imprimirIngrediente() {
		System.out.println("----------------------------------");
		System.out.println("nombre: "+nombre);
		System.out.println("Categoria: "+categoria);
		System.out.println("Precio: Lps."+precio);
		System.out.println("----------------------------------");
	}
 
	public void listarIngre(int opcion) {
		System.out.println(opcion + " "+nombre + " "+categoria + " "+ " (Lps."+precio+") ");
	}
 
	public String pedirNombre() {
		@SuppressWarnings("resource")
		Scanner teclado = new Scanner(System.in);
		System.out.println("Ingrese el nombre del ingrediente");
		return teclado.nextLine();
	}
 
	public String pedirCategoria() {
 
		@SuppressWarnings("resource")
		Scanner teclado = new Scanner(System.in);
		System.out.println("Ingrese la categoria del ingrediente:");
		return teclado.nextLine();
	}
 
	public double pedirPrecio() {
		@SuppressWarnings("resource")
		Scanner teclado = new Scanner(System.in);
		System.out.println("Ingrese el precio del ingrediente:");
		return teclado.nextInt();
 
 
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder