11package terminalcli ;
22import coreapi ;
3+ import api .src .main .java .coreapi .*;
4+
35import java .io .*;
4- import java .util .Scanner ;
6+ import java .util .*;
7+ import java .time .LocalDate ;
8+ import java .lang .*;
59
610public class Screen
711{
8- /* Main Screen */
12+ /*--------------------------------------- MAIN_SCREEN --------------------------------------------- */
913
1014 public void main_screen (Cafeteria coffe )
1115 {
1216 String op ;
1317 int s = 0 ;
1418 Scanner keyboard = new Scanner (System .in );
19+
1520 do
1621 {
1722 System .out .println ("Software de " + coffe .getName ());
@@ -22,6 +27,7 @@ public void main_screen(Cafeteria coffe)
2227 System .out .println ("---------------------------------------------" );
2328 System .out .println ("Introduzca una opcion:" );
2429 op = keyboard .nextString ();
30+
2531 if (op .compareTo ("Q" ))
2632 {
2733 System .exit ();
@@ -32,29 +38,40 @@ public void main_screen(Cafeteria coffe)
3238 switch (s )
3339 {
3440 case 1 :
35- OrderInProgress_screen (coffe );
41+
42+ Order ord = OrderFactory .createOrder (coffe );
43+ OrderInProgress_screen (coffe ,ord );
3644 break ;
3745
3846 case 2 :
39- Date date ;
47+
48+ int d ,m ,y ;
49+ Scanner keyboard = new Scanner (System .in );
50+ System .out .println ("Introduce la fecha de la caja del dia que quiere consultar (dia, mes y año):" );
51+ d = keyboard .nextInt ();
52+ m = keyboard .nextInt ();
53+ y = keyboard .nextInt ();
54+ LocalDate date = LocalDate .of (y ,m ,d );
55+
4056 DailyRegister_screen (coffe , date );
4157 break ;
4258
4359 default :
4460 System .out .println ("Introduzca una opcion valida." );
4561 }
4662 }
63+
4764 }while (s != 1 || s != 2 );
4865 }
4966
50- /* Order in Progress Screen */
67+ /*-------------------------------------- ORDER_IN_PROGRESS_SCREEN -------------------------------------- */
5168
52- public void OrderInProgress_screen (Cafeteria coffe )
69+ public void OrderInProgress_screen (Cafeteria coffe , Order ord )
5370 {
5471 String op ;
5572 int s = 0 ;
5673 Scanner keyboard = new Scanner (System .in );
57- Order ord = createOrder ( coffe );
74+
5875 do
5976 {
6077 System .out .println ("Pedido en curso (" + ord .getOrderCount () + ")" );
@@ -67,6 +84,7 @@ public void OrderInProgress_screen(Cafeteria coffe)
6784 System .out .println ("---------------------------------------------" );
6885 System .out .println ("Introduzca una opcion:" );
6986 op = keyboard .nextString ();
87+
7088 if (op .compareTo ("R" ))
7189 {
7290 main_screen (coffe );
@@ -77,15 +95,15 @@ public void OrderInProgress_screen(Cafeteria coffe)
7795 switch (s )
7896 {
7997 case 1 :
80- type_screen (coffe );
98+ type_screen (coffe , ord );
8199 break ;
82100
83101 case 2 :
84- Remove_Product_screen (ord );
102+ Remove_Product_screen (coffe , ord );
85103 break ;
86104
87105 case 3 :
88- Finish_Order_screen (ord );
106+ Finish_Order_screen (coffe , ord );
89107 break ;
90108
91109 default :
@@ -95,27 +113,26 @@ public void OrderInProgress_screen(Cafeteria coffe)
95113 }while (s != 1 || s != 2 || op != 3 );
96114 }
97115
98- /* Select Type Screen */
116+ /* ------------------------------SELECT_TYPE_SCREEN ------------------------------------- */
99117
100- public void type_screen (Cafeteria coffe )
118+ public void type_screen (Cafeteria coffe , Order ord ) //Terminar
101119 {
102120 String op ;
103121 int s = 0 , range = 0 ;
104122 Scanner keyboard = new Scanner (System .in );
105- //Crear lista de tipos en productCatalog?
106123 List <String > typeProduct = coffe .getTypes ();
107124 do
108125 {
109126 System .out .println ("Tipo de productos" );
110127 System .out .println ("---------------------------------------------" );
111- for (String s : typeProduct )
128+ for (String type : typeProduct )
112129 {
113130 range = range + 1 ;
114- System .out .println (range + '.' + s );
131+ System .out .println (range + '.' + type );
115132 }
116133 System .out .println ("R. Volver a pantalla anterior" );
117134 System .out .println ("---------------------------------------------" );
118- System .out .println ("Introduzca una opci�n " );
135+ System .out .println ("Introduzca una opcion " );
119136 op = keyboard .nextString ();
120137 if (op .compareTo ("R" ))
121138 {
@@ -125,19 +142,18 @@ public void type_screen(Cafeteria coffe)
125142 {
126143 s = Interger .parseInt (op );
127144 if (s < 1 || s > range )
128- System .out .println ("Introduzca una opci�n v�lida " );
145+ System .out .println ("Introduzca una opcion valida " );
129146 else
130147 {
131- //Funci�n Cafeteria que muestre los productos de ese tipo. Pondr�a product Screen y que
132- // esta recibiese el tipo tambi�n.
148+
133149 }
134150 }
135151 }while (s < 1 || s > range );
136152 }
137153
138- /* Select Product Screen */
154+ /*-------------------------------- SELECT_PRODUCT_SCREEN ------------------------------------ */
139155
140- public void product_screen (Cafeteria coffe )
156+ public void product_screen (Cafeteria coffe , Order ord , String type ) //Terminar
141157 {
142158 String op ;
143159 int s = 0 , range = 0 ;
@@ -155,7 +171,7 @@ public void product_screen(Cafeteria coffe)
155171 }
156172 System .out .println ("R. Volver a pantalla anterior" );
157173 System .out .println ("---------------------------------------------" );
158- System .out .println ("Introduzca una opci�n " );
174+ System .out .println ("Introduzca una opcion " );
159175 op = keyboard .nextString ();
160176 if (op .compareTo ("R" ))
161177 {
@@ -165,7 +181,7 @@ public void product_screen(Cafeteria coffe)
165181 {
166182 s = Interger .parseInt (op );
167183 if (s < 1 || s > range )
168- System .out .println ("Introduzca una opci�n v�lida " );
184+ System .out .println ("Introduzca una opcion valida " );
169185 else
170186 {
171187 //�Funciones para un producto?
@@ -174,17 +190,18 @@ public void product_screen(Cafeteria coffe)
174190 }while (s < 1 || s > range );
175191 }
176192
177- /* Delete Product Screen */
193+ /*------------------------------------ DELETE_PRODUCT_SCREEN---------------------------------------- */
178194
179- public void Remove_Product_screen (Order ord ) // FALTA
195+ public void Remove_Product_screen (Cafeteria coffe , Order ord )
180196 {
181- int s = 0 ;
197+ int s = 0 , cont = 0 , q = 0 ;
182198 String op , range = 0 ;
183199 Scanner keyboard = new Scanner (System .in );
184200 Map <Product ,int > basket = ord .getBasket ();
201+ Iterator it = basket .keySet ().iterator ();
185202 do
186203 {
187- System .out .println (Eliminar producto del pedido );
204+ System .out .println (" Eliminar producto del pedido" );
188205 System .out .println ("---------------------------------------------" );
189206 for (Map .Entry <Product , Integer > entry : basket .entrySet ())
190207 {
@@ -214,7 +231,7 @@ public void Remove_Product_screen(Order ord) // FALTA
214231 }
215232 System .out .println ("R. Volver a pantalla anterior" );
216233 System .out .println ("---------------------------------------------" );
217- System .out .println ("Introduzca una opci�n " );
234+ System .out .println ("Introduzca una opcion " );
218235 op = kayboard .nextString ();
219236 if (op .compareTo ("R" ))
220237 {
@@ -225,33 +242,41 @@ public void Remove_Product_screen(Order ord) // FALTA
225242 s = Interger .parseTo (op );
226243 if (op < 1 && op > range )
227244 {
228- System .out .println ("Introduzca una opci�n v�lida " );
245+ System .out .println ("Introduzca una opcion valida " );
229246 }
230247 else
231248 {
232- //Funci�n para eliminar producto
249+ System .out .println ("Introduce la cantidad de producto a eliminar:" );
250+ q = kayboard .nextInt ();
251+ while (cont < s && it .hasNext ())
252+ {
253+ cont ++;
254+ }
255+ OrderService .removeProductFromOrder (ord , it .next ().getId (), q );
233256 }
234257 }
235258 }while (op < 1 || op > range );
236259 }
237260
238- /* Finish Order Screen */
261+ /*----------------------------------- FINISH_ORDER_SCREEM ----------------------------------- */
239262
240- public void Finish_Order_screen (Order ord )
263+ public void Finish_Order_screen (Cafeteria coffe , Order ord )
241264 {
242265 int s = 0 ;
243266 String op ;
244267 Scanner keyboard = new Scanner (System .in );
245268 List <Product > AvailableProduct = coffe .getAvailableProducts ();
269+
246270 do
247271 {
248272 System .out .println ("Pedido en curso(" + ord .getId () + ')' );
249273 System .out .println ("---------------------------------------------" );
250274 System .out .println ("1. Pagar y finalizar pedido" );
251275 System .out .println ("R. Volver a pantalla anterior" );
252276 System .out .println ("---------------------------------------------" );
253- System .out .println ("Introduzca una opci�n " );
277+ System .out .println ("Introduzca una opcion " );
254278 op = keyboard .nextString ();
279+
255280 if (op .comparteTo ("R" ))
256281 {
257282 OrderInProgress_screen (coffe );
@@ -261,24 +286,28 @@ public void Finish_Order_screen(Order ord)
261286 s = Interger .parseTo (op );
262287 if (s == 1 )
263288 {
289+ OrderService .OrderStatus_Payed (ord );
264290 OrderService .OrderStatus_Finished (ord );
291+ main_screen (coffe );
265292 }
266293 else
267294 {
268- System .out .println ("Introduzca una opci�n v�lida " );
295+ System .out .println ("Introduzca una opcion valida " );
269296 }
270297 }
271- }while (s < 1 || s > range );
298+
299+ }while (s != 1 );
272300 }
273301
274- /* Daily Register Screen */
302+ /*------------------------------ DAILY_REGISTER_SCREEN--------------------------------- */
275303
276- public void DailyRegister_screen (Cafeteria coffe , Date date )
304+ public void DailyRegister_screen (Cafeteria coffe , LocalDate date )
277305 {
278306 char op ;
279- int n_orders = //N� pedidos
307+ int n_orders = OrderService . getNumberOfOrdersDailyRegister ( coffe , date );
280308 BigDecimal daily = getDailyRegister (coffe ,date );
281309 Scanner keyboard = new Scanner (System .in );
310+
282311 do
283312 {
284313 System .out .println ("Tipo de productos" );
@@ -287,16 +316,18 @@ public void DailyRegister_screen(Cafeteria coffe, Date date)
287316 System .out .println ("Caja: " + daily );
288317 System .out .println ("R. Volver a pantalla anterior" );
289318 System .out .println ("---------------------------------------------" );
290- System .out .println ("Introduzca una opci�n " );
319+ System .out .println ("Introduzca una opcion " );
291320 op = keyboard .nextChar ();
321+
292322 if (op != 'R' )
293323 {
294- System .out .println ("Introduzca una opci�n v�lida " );
324+ System .out .println ("Introduzca una opcion valida " );
295325 }
296326 else
297327 {
298328 main_screen (coffe );
299329 }
330+
300331 }while (op != 'R' );
301332 }
302333
0 commit comments