Está en la página 1de 25

CENTRO UNIVERSITRIO UNIA ANHANGUERA SANTO ANDR

RELATRIO 3 PROGRAMAO ORIENTADA A OBJETOS

SANTO ANDR
JUNHO DE 2014

RELATRIO 1

TELAS E CDIGO COMENTADO

ENTRADA

SADA

POUSADA_MARAU.JAVA
package pousada_marau;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
abstract class Pousada{
// Nome do locatrio
private String nome;
// Dados de data de entrada
private int diaEntrada;
private int mesEntrada;
private int anoEntrada;
private int horasEntrada;
private int minutosEntrada;
// Dados de data de sada
private int diaSaida;
private int mesSaida;
private int anoSaida;
private int horasSaida;
private int minutosSaida;
//Tipo de acomodao
private int _tipoAcomodacao;
private int _valorDiaria;
//
public int qtdCamasExtras = 0;
//Nmero da ocupao
public boolean ocupado = false;
// Valores calculados
private int diarias;
private int valorTotal;
// Registra a data de entrada
public void setEntrada (int dia, int mes, int ano, int horas, int minutos, int
qtdCamasExtras)
{
this.diaEntrada = dia;
this.mesEntrada = mes;
this.anoEntrada = ano;
this.horasEntrada = horas;
this.minutosEntrada = minutos;
this.ocupado
= true;
this.qtdCamasExtras = 0;

}
// Registra a data de sada
public void setSaida (int dia, int mes, int ano, int horas, int minutos)
{
this.diaSaida = dia;
this.mesSaida = mes;
this.anoSaida = ano;
this.horasSaida = horas;
this.minutosSaida = minutos;
this.ocupado
= false;
}
protected abstract String tipoAcomodacao ();
// Valor da diria
protected abstract double valorDiaria();

// Resgata a data de entrada


public String getEntrada ()
{
String data = String.valueOf(this.diaEntrada);
data += "/" + String.valueOf(this.mesEntrada);
data += "/" + String.valueOf(this.anoEntrada);
data += " " + String.valueOf(this.horasEntrada);
data += ":" + String.valueOf(this.minutosEntrada);
return data;
}
// Resgata a data de sada
public String getSaida ()
{
String data = String.valueOf(this.diaSaida);
data += "/" + String.valueOf(this.mesSaida);
data += "/" + String.valueOf(this.anoSaida);
data += " " + String.valueOf(this.horasSaida);
data += ":" + String.valueOf(this.minutosSaida);
return data;
}
// Registra os dados da diria
public void DadosDiaria (String nome, double valor)
{
this.nome = nome;
valor = valor * 100;
this._valorDiaria = (int)Math.floor(valor);
}
3

// Resgata o nome do locatrio


public String locatario ()
{
return this.nome;
}
// Resgata o nmero de dias que o locatrio usou o quarto
public int diarias ()
{
return this.diarias;
}
// Resgata o valor total devido pelo locatrio
public String totalDevido()
{
float vlTotal = (float) (this.valorTotal / 100.0);
vlTotal *= valorDiaria() * (1.0 + (double)this.qtdCamasExtras / 10);
DecimalFormat form = new DecimalFormat("0.00");
return form.format(vlTotal);
}
// Calcula a quantidade de dirias e o valor total
public void Calcular ()
{
int diarias = this.diaSaida - this.diaEntrada;
diarias += (this.mesSaida - this.mesEntrada) * 30;
diarias += (this.anoSaida - this.anoEntrada) * 365;
if (this.horasEntrada < 12)
{
diarias ++;
}
if (this.horasSaida >= 12)
{
diarias ++;
}
this.diarias = diarias;
this.valorTotal = diarias * this._valorDiaria;
}
}

class Quarto extends Pousada {


@Override
protected String tipoAcomodacao() {
4

return "Quarto";
}
@Override
protected double valorDiaria() {
return 1.0;
}
}

class Chale extends Pousada {


@Override
protected String tipoAcomodacao() {
return "Chal";
}
@Override
protected double valorDiaria() {
return 1.2;
}
@Override
public void setEntrada (int dia, int mes, int ano, int horas, int minutos, int
camasExtras)
{
super.setEntrada(dia, mes, ano, horas, minutos, camasExtras);
this.qtdCamasExtras = camasExtras;
}
}
public class Pousada_marau {
private Pousada quartos[] = new Pousada[60];
public static void main(String[] args) {
Pousada_marau p = new Pousada_marau();
for (int i = 0; i < 50; i++) {
p.quartos[i] = new Quarto();
}
for (int i = 50; i < 60; i++) {
p.quartos[i] = new Chale();
}
Menu m = new Menu();
m.setQuartos(p.quartos);
5

m.setVisible(true);
/*

int tpAcomodacao = 0;// Tipo de acomodao 1 - Quarto 2 - Chal


int nrQuarto = 0;
//Variaveis de Entrada
String Nom_Loc = e.txtNomLoc.getText();
double VDiaria = Double.parseDouble(e.txtValDiaria.getText());
int DiaEnt = Integer.parseInt(e.txtDiaEnt.getText());
int MesEnt = Integer.parseInt(e.txtMesEnt.getText());
int AnoEnt = Integer.parseInt(e.txtAnoEnt.getText());
int HoraEnt = Integer.parseInt(e.txtHorEnt.getText());
int MinEnt = Integer.parseInt(e.txtMinEnt.getText());
int NumCamExt = Integer.parseInt(e.txtCamExt.getText());
//Variaveis de Saida
nrQuarto = Integer.parseInt(e.txtNumAcomod.getText());
// Calcula a posio no vetor de acordo com no tipo
int indexAcomodacao = tpAcomodacao == 1 ? -1 : 49;
// Calcula a posio exata do quarto no vetor
int numQuarto = indexAcomodacao + nrQuarto;
// Se o quarto no estiver na lista da erro
if(numQuarto > 59 || numQuarto < 0) {
JOptionPane.showMessageDialog(null,"Quarto Indisponvel");
}

if (!p.quartos[numQuarto].ocupado) {
// @PARAM: Nome do locatrio, Valor da diria
p.quartos[numQuarto].DadosDiaria(Nom_Loc, VDiaria);
// @PARAM: Dia, Ms, Ano, Hora, Minuto de entrada
p.quartos[numQuarto].setEntrada(DiaEnt,MesEnt,AnoEnt,
MinEnt, NumCamExt);
}
// @PARAM: Dia, Ms, Ano, Hora, Minuto de saida
p.quartos[numQuarto].setSaida(DiaSaida,
MesSaida,
HoraSaida, MinSaida);

HoraEnt,

AnoSaida,

// Faz o calculo de dirias


p.quartos[numQuarto].Calcular();
// Pega o valor devido
System.out.println(p.quartos[numQuarto].totalDevido());
*/
}
6

}
MENU.JAVA
package pousada_marau;
public class Menu extends javax.swing.JFrame {
private Pousada quartos[];
public void setQuartos (Pousada quartos[]) {
this.quartos = quartos;
}
public Menu() {
super("Menu");
initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
btnEntrada = new javax.swing.JButton();
btnSaida = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnEntrada.setLabel("Registro de Entrada de Hspede");
btnEntrada.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEntradaActionPerformed(evt);
}
});
btnSaida.setLabel("Registro de Sada de Hspede");
btnSaida.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSaidaActionPerformed(evt);
}
});
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
7

.addContainerGap(53, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING, false)
.addComponent(btnSaida,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnEntrada))
.addGap(49, 49, 49))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addComponent(btnEntrada)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(btnSaida)
.addContainerGap())
);
pack();
}// </editor-fold>
private void btnEntradaActionPerformed(java.awt.event.ActionEvent evt) {
Registro_Entrada e = new Registro_Entrada();
e.setQuartos(this.quartos);
e.setVisible(true);
}
private void btnSaidaActionPerformed(java.awt.event.ActionEvent evt) {
Registro_Saida s = new Registro_Saida();
s.setQuartos(this.quartos);
s.setVisible(true);
}

public static void main(String args[]) {

java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Menu().setVisible(true);
}
});
}
8

// Variables declaration - do not modify


private javax.swing.JButton btnEntrada;
private javax.swing.JButton btnSaida;
// End of variables declaration
}
REGISTRO_SAIDA.JAVA
package pousada_marau;
import javax.swing.*;
/**
*
* @author Walter
*/
public class Registro_Saida extends javax.swing.JFrame {
private Pousada quartos[];
/**
* Creates new form Registro_Saida
*/
public Registro_Saida() {
super("Registro de Sada de Hspede");
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
txtDiaSaida = new javax.swing.JTextField();
txtMesSaida = new javax.swing.JTextField();
txtAnoSaida = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtHorSaida = new javax.swing.JTextField();
btnRecibo = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
txtNumAcomod = new javax.swing.JTextField();
txtMinSaida = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setText("Data de Sada:");
jLabel2.setText("/");
jLabel3.setText("/");
jLabel5.setText("Horrio de Sada:");
btnRecibo.setText("Emitir Recibo");
btnRecibo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnReciboActionPerformed(evt);
}
});
jLabel6.setText("Nmero da Acomodao:");
txtNumAcomod.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtNumAcomodActionPerformed(evt);
}
});
jLabel7.setText(":");
javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtNumAcomod,
javax.swing.GroupLayout.PREFERRED_SIZE,
39,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
33, Short.MAX_VALUE)
.addComponent(btnRecibo))
.addGroup(layout.createSequentialGroup()

10

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(txtHorSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtMinSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(24, 24, 24)
.addComponent(txtDiaSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
31,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addGap(5, 5, 5)
.addComponent(txtMesSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
31,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtAnoSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
51,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()

11

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel1)
.addComponent(txtDiaSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMesSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtAnoSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel5)
.addComponent(txtHorSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(txtMinSaida,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel6)
.addComponent(txtNumAcomod,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnRecibo))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
12

private void btnReciboActionPerformed(java.awt.event.ActionEvent evt) {


//Pousada_marau p = new Pousada_marau();
int DiaSaida = Integer.parseInt(txtDiaSaida.getText());
int MesSaida = Integer.parseInt(txtMesSaida.getText());
int AnoSaida = Integer.parseInt(txtAnoSaida.getText());
int HoraSaida = Integer.parseInt(txtHorSaida.getText());
int MinSaida = Integer.parseInt(txtMinSaida.getText());
int nrQuarto = Integer.parseInt(txtNumAcomod.getText());
if (nrQuarto < 1 || nrQuarto > 60) {
JOptionPane.showMessageDialog(null, "Quarto no existe");
return;
}
nrQuarto--;
if (!quartos[nrQuarto].ocupado) {
JOptionPane.showMessageDialog(null, "Quarto j se encontra livre");
}
quartos[nrQuarto].setSaida(DiaSaida, MesSaida, AnoSaida, HoraSaida,
MinSaida);
quartos[nrQuarto].Calcular();
JOptionPane.showMessageDialog(null,
"Nome
do
Hspede:
"
+
quartos[nrQuarto].locatario() +
"\n Data e horrio de entrada: " + quartos[nrQuarto].getEntrada() +
"\n Data e horrio de sada: " + quartos[nrQuarto].getSaida() +
"\n Nmero de dirias: " + quartos[nrQuarto].diarias() + "\n Total Devido: "
+
quartos[nrQuarto].totalDevido());
}
private void txtNumAcomodActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code
(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.

13

*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for
(javax.swing.UIManager.LookAndFeelInfo
info
:
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Registro_Saida.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Registro_Saida.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Registro_Saida.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Registro_Saida.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Registro_Saida().setVisible(true);
}
});
}
// Variables declaration - do not modify
public javax.swing.JButton btnRecibo;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
public javax.swing.JTextField txtAnoSaida;
public javax.swing.JTextField txtDiaSaida;
public javax.swing.JTextField txtHorSaida;
14

public javax.swing.JTextField txtMesSaida;


public javax.swing.JTextField txtMinSaida;
public javax.swing.JTextField txtNumAcomod;
// End of variables declaration
void setQuartos(Pousada[] quartos) {
this.quartos = quartos;
}
}
REGISTRO_ENTRADA.JAVA
package pousada_marau;
//import java.awt.*;
//import java.awt.event.*;
import javax.swing.JOptionPane;
//import javax.swing.*;
//import javax.swing.event.*;
/**
*
* @author Walter
*/
public class Registro_Entrada extends javax.swing.JFrame {
private Pousada quartos[];
/**
* Creates new form Registro_Entrada
*/
public Registro_Entrada() {
super("Registro de Entrada de Hspede");
initComponents();
}
public void setQuartos (Pousada quartos[]) {
this.quartos = quartos;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
rbnQuarto = new javax.swing.JRadioButton();
15

rbnChale = new javax.swing.JRadioButton();


jLabel1 = new javax.swing.JLabel();
txtNomLoc = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
txtDiaEnt = new javax.swing.JTextField();
txtMesEnt = new javax.swing.JTextField();
txtAnoEnt = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
txtHorEnt = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtValDiaria = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
txtMinEnt = new javax.swing.JTextField();
lblCamExt = new javax.swing.JLabel();
txtCamExt = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
txtNumAcomod = new javax.swing.JTextField();
lblAcomod = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOS
E);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tipo de
Acomodao"));
buttonGroup1.add(rbnQuarto);
rbnQuarto.setText("Quarto");
rbnQuarto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rbnQuartoActionPerformed(evt);
}
});
buttonGroup1.add(rbnChale);
rbnChale.setText("Chal");
rbnChale.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rbnChaleActionPerformed(evt);
}
});
javax.swing.GroupLayout
jPanel1Layout
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(

new

16

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(rbnQuarto)
.addGap(18, 18, 18)
.addComponent(rbnChale)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align
ment.BASELINE)
.addComponent(rbnQuarto)
.addComponent(rbnChale))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
jLabel1.setText("Nome do Hspede:");
jLabel2.setText("Data de Entrada:");
jLabel3.setText("/");
jLabel4.setText("/");
jLabel5.setText("Horrio de Entrada:");
jLabel6.setText("Valor da Diria:");
jLabel7.setText(":");
lblCamExt.setText("Nmero de Camas Extras:");
jButton1.setText("REGISTRAR");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
lblAcomod.setText("Acomodao");
17

javax.swing.GroupLayout
layout
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

new

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(txtHorEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtMinEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
33,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtValDiaria,
javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)

18

.addComponent(txtDiaEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)

31,

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(txtMesEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
31,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(txtAnoEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
48,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblCamExt)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtCamExt,
javax.swing.GroupLayout.PREFERRED_SIZE,
39,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblAcomod)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtNumAcomod,
javax.swing.GroupLayout.PREFERRED_SIZE,
36,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)

19

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addComponent(txtNomLoc,
javax.swing.GroupLayout.PREFERRED_SIZE,
169,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel1)
.addComponent(txtNomLoc,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel2)
.addComponent(txtDiaEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(txtMesEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(txtAnoEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
20

.addComponent(jLabel5)
.addComponent(txtHorEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(txtMinEnt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(jLabel6)
.addComponent(txtValDiaria,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(lblCamExt)
.addComponent(txtCamExt,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATE
D)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(txtNumAcomod,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblAcomod))))
21

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void rbnQuartoActionPerformed(java.awt.event.ActionEvent evt) {
if (rbnQuarto.isSelected())
lblAcomod.setText("Quarto N");
}
private void rbnChaleActionPerformed(java.awt.event.ActionEvent evt) {
if (rbnChale.isSelected()){
lblAcomod.setText("Chal N");
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO A lgica referente a entrada vai aqui
String Nom_Loc = txtNomLoc.getText();
double VDiaria = Double.parseDouble(txtValDiaria.getText());
int DiaEnt = Integer.parseInt(txtDiaEnt.getText());
int MesEnt = Integer.parseInt(txtMesEnt.getText());
int AnoEnt = Integer.parseInt(txtAnoEnt.getText());
int HoraEnt = Integer.parseInt(txtHorEnt.getText());
int MinEnt = Integer.parseInt(txtMinEnt.getText());
int NumCamExt = Integer.parseInt(txtCamExt.getText());
int nrQuarto = Integer.parseInt(txtNumAcomod.getText());
// Se o quarto no estiver na lista da erro
if(nrQuarto > 50 || nrQuarto < 1) {
JOptionPane.showMessageDialog(null,"Quarto Indisponvel");
return;
}
if (rbnChale.isSelected() && nrQuarto > 10) {
JOptionPane.showMessageDialog(null,"Quarto Indisponvel");
return;
}
if (rbnChale.isSelected()) {
nrQuarto += 49;
} else {
nrQuarto--;
}

if (!quartos[nrQuarto].ocupado) {
22

quartos[nrQuarto].DadosDiaria(Nom_Loc, VDiaria);
// @PARAM: Dia, Ms, Ano, Hora, Minuto de entrada
quartos[nrQuarto].setEntrada(DiaEnt,MesEnt,AnoEnt, HoraEnt, MinEnt,
NumCamExt);
this.setVisible(false);
} else {
JOptionPane.showMessageDialog(null,
"O
quarto
encontra-se
ocupado.");
return;
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code


(optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default
look and feel.
*
For
details
see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for
(javax.swing.UIManager.LookAndFeelInfo
info
:
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Registro_Entrada.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Registro_Entrada.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Registro_Entrada.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

23

java.util.logging.Logger.getLogger(Registro_Entrada.class.getName()).log(java.
util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Registro_Entrada().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblAcomod;
private javax.swing.JLabel lblCamExt;
public javax.swing.JRadioButton rbnChale;
public javax.swing.JRadioButton rbnQuarto;
public javax.swing.JTextField txtAnoEnt;
public javax.swing.JTextField txtCamExt;
public javax.swing.JTextField txtDiaEnt;
public javax.swing.JTextField txtHorEnt;
public javax.swing.JTextField txtMesEnt;
public javax.swing.JTextField txtMinEnt;
public javax.swing.JTextField txtNomLoc;
public javax.swing.JTextField txtNumAcomod;
public javax.swing.JTextField txtValDiaria;
// End of variables declaration
}

24

También podría gustarte