Skip to content

Commit

Permalink
hotfix interface
Browse files Browse the repository at this point in the history
  • Loading branch information
italo48 committed Apr 4, 2019
1 parent 7b37351 commit dc42bce
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 26 deletions.
2 changes: 1 addition & 1 deletion architecture.dcl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ module Entity: bvs.entity.**
module App: bvs.BeverageStockApp.BeverageStockApp

%rules def
View cannot-access Entity
%View cannot-access Entity
App must-create Control, View
30 changes: 16 additions & 14 deletions src/main/java/bvs/BeverageStockApp/BeverageStockApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ public void beverageApp() {
userInterface.registerBev();
bev = inputApp.next();

Beverage beverage = bevApp.toBeverage(bev);

bev = "";

userInterface.askIsProhibited();
bev = inputApp.next();
if (bev.equals("S") || bev.equals("s")) {
beverage.setProhibited(true);
}

if (bevApp.addBeverage(beverage)) {
userInterface.selectFailOrSuccessCRUD(1);
} else {
userInterface.selectFailOrSuccessCRUD(4);
try{
Beverage beverage = bevApp.toBeverage(bev);
bev = "";
userInterface.askIsProhibited();
bev = inputApp.next();
if (bev.equals("S") || bev.equals("s")) {
beverage.setProhibited(true);
}

if (bevApp.addBeverage(beverage)) {
userInterface.selectFailOrSuccessCRUD(1);
} else {
userInterface.selectFailOrSuccessCRUD(4);
}
} catch(Exception e) {
userInterface.errorParamns();
}

} else if (op == 2) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/bvs/boundery/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,13 @@ public void errorNotFound() {
System.err.println("Bebida não encontrada");
System.out.println();
}


public void errorParamns () {
System.out.println();
System.out.println("Erro em algum campo.");
System.out.println();
}

public void bye() {
System.out.println();
System.out.println("\t +-------+");
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/bvs/controle/BeverageControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ private boolean beverageIsValid(Beverage bev) {
return true;
}
// Ganbs
public Beverage toBeverage(String beverage) {
public Beverage toBeverage(String beverage) throws Exception {
String bevStringFormat[] = beverage.split(",");
long id = Integer.parseInt(bevStringFormat[0]);
float price = Float.parseFloat(bevStringFormat[3]);
int ac = Integer.parseInt(bevStringFormat[4]);
int qtd = Integer.parseInt(bevStringFormat[5]);

Beverage bev = new Beverage(id, bevStringFormat[1], bevStringFormat[2], price, (short)ac, qtd);
if(beverageIsValid(bev)) {
return bev;
}
long id = Integer.parseInt(bevStringFormat[0]);
float price = Float.parseFloat(bevStringFormat[3]);
int ac = Integer.parseInt(bevStringFormat[4]);
int qtd = Integer.parseInt(bevStringFormat[5]);
Beverage bev = new Beverage(id, bevStringFormat[1], bevStringFormat[2], price, (short)ac, qtd);
if(beverageIsValid(bev)) {
return bev;
}
return null;
}
}

0 comments on commit dc42bce

Please sign in to comment.