-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurante.java
More file actions
90 lines (86 loc) · 3.36 KB
/
Copy pathRestaurante.java
File metadata and controls
90 lines (86 loc) · 3.36 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
81
82
83
84
85
86
87
88
89
90
package LPJoelGraca;
public class Restaurante {
// Constantes
private static final float MENU_PEIXE = 250.0f;
private static final float MENU_CARNE = 250.0f;
// Variáveis de intância
private int QntdPeixe;
private int QntdCarne;
private float despMenuPeixe;
private float despMenuCarne;
private float valorPagar;
private float valorTotal;
private float valorDobra;
private float teveLucro;
private float descontoP;
private float descontoC;
public Restaurante(){
this.QntdPeixe = 0;
this.QntdCarne = 0;
this.despMenuPeixe = 300.0f;
this.despMenuCarne = 300.0f;
this.valorPagar = 0.0f;
this.valorTotal = 0.0f;
this.valorDobra = 0.0f;
this.teveLucro = 0.0f;
this.descontoP = 0.0f;
this.descontoC = 0.0f;
}
public Restaurante(float despMenuPeixe, float despMenuCarne){
this.despMenuPeixe = despMenuPeixe;
this.despMenuCarne = despMenuCarne;
}
// realiza os pedidos dos menus e verifica o valor a ser pago
public float pedido(int numeroDePeixe, int numeroCarne){
this.QntdPeixe = numeroDePeixe;
this.QntdCarne = numeroCarne;
if (QntdPeixe > 2 && QntdCarne > 2) { // mais de dois menus cada
descontoP = ((MENU_PEIXE * QntdPeixe) * 20 ) / 100;
descontoC = ((MENU_CARNE * QntdCarne) * 20 ) / 100;
valorPagar = ((MENU_PEIXE * QntdPeixe) - descontoP) + ((MENU_CARNE * QntdCarne) - descontoC);
}else{ // Caso não, calcular a quantidades de menus vendidos
valorPagar = (MENU_PEIXE * QntdPeixe) + (MENU_CARNE * QntdCarne);
}
return valorPagar;
}
// retorna o número de menus vendidos a um preço normal
public int menusPrecoNormal(){
int precoNormal = 0;
if (QntdPeixe <= 2 && QntdCarne <= 2) { // caso os menus não sejam mais de 2
precoNormal = (int) ((MENU_PEIXE * QntdPeixe) + (MENU_CARNE * QntdCarne));
}else if(QntdPeixe <= 2 && QntdCarne > 2 || QntdPeixe > 2 && QntdCarne <= 2){ // caso apenas um menu seja pedido mais de duas vezes
precoNormal = (int) ((MENU_PEIXE * QntdPeixe) + (MENU_CARNE * QntdCarne));
}
return precoNormal;
}
// retorna o número de menus vendidos a um preço reduzido
public int menusPrecoReduzido(){
int precoReduzido = 0;
if (QntdPeixe > 2 && QntdCarne > 2){
precoReduzido = (int)valorPagar;
}
return precoReduzido;
}
// valor total abtido das vendas
public float valorVenda(){
this.valorTotal = valorPagar;
return this.valorTotal;
}
// valor a pagar ao imposto de (15%)
public float iva(){
this.valorDobra = (valorTotal * 15) / 100;
return this.valorDobra;
}
// calcula o lucro do restaurante, valor normal e reduzido, mas o iva
public float lucro(){
teveLucro = (this.valorVenda() - this.iva()); // já contém a venda em valor normal ou reduzido
return this.teveLucro;
}
// verifica se o restaurante teve lucro
public boolean teveLucro() {
if(this.lucro() > (despMenuPeixe + despMenuCarne)){ // caso o lucro seja superior a despesa dos menus
return true;
}
return false;
}
}