id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
3409a47b-844f-4206-a212-c3da59cc3e3e | public int getAncho() {
return (new ImageIcon(animo.getImagen()).getIconWidth());
} |
a23c93f9-3e03-4343-b1bb-88de80a4a62d | public int getAlto() {
return (new ImageIcon(animo.getImagen()).getIconHeight());
} |
780bc77a-0fc1-47ab-a6ae-736abe89df8b | public Image getImagenI() {
return (new ImageIcon(animo.getImagen()).getImage());
} |
1486e621-8ed7-4f89-a5cf-69863abf2dfa | public Rectangle getPerimetro() {
return new Rectangle(getPosX(), getPosY(), getAncho(), getAlto());
} |
bf421b89-53cf-4eaa-811e-43a4ce8000ae | public boolean intersecta(Base obj) {
return getPerimetro().intersects(obj.getPerimetro());
} |
062b6a41-7a13-4db9-8b8f-17ac09fa3eee | public boolean contiene(int posX, int posY) {
return getPerimetro().contains(posX, posY);
} |
8ca476ab-7979-49a5-835e-2778d1e8be43 | public void actualiza(long tiempo) {
animo.actualiza(tiempo);
} |
68534ab5-2610-412b-bbb9-2108817269bb | public Bueno(int posX, int posY) {
super(posX, posY);
Image tank0 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank0.gif"));
Image tank1 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank1.gif"));
Image tank2 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank2.gif"));
Image tank3 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank3.gif"));
Image tank4 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank4.gif"));
Image tank5 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank5.gif"));
Image tank6 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank6.gif"));
Image tank7 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank7.gif"));
Image tank8 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank8.gif"));
Image tank9 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank9.gif"));
Image tank10 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank10.gif"));
Image tank11 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank11.gif"));
Image tank12 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank12.gif"));
Image tank13 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank13.gif"));
Image tank14 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank14.gif"));
Image tank15 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank15.gif"));
Image tank16 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank16.gif"));
Image tank17 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank17.gif"));
Image tank18 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank18.gif"));
Image tank19 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank19.gif"));
Image tank20 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank20.gif"));
Image tank21 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank21.gif"));
Image tank22 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank22.gif"));
Image tank23 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank23.gif"));
Image tank24 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank24.gif"));
Image tank25 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank25.gif"));
Image tank26 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank26.gif"));
Image tank27 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank27.gif"));
Image tank28 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank28.gif"));
Image tank29 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank29.gif"));
Image tank30 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank30.gif"));
Image tank31 = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("Images/tank31.gif"));
animo = new Animacion();
animo.sumaCuadro(tank0, 100);
animo.sumaCuadro(tank1, 100);
animo.sumaCuadro(tank2, 100);
animo.sumaCuadro(tank3, 100);
animo.sumaCuadro(tank4, 100);
animo.sumaCuadro(tank5, 100);
animo.sumaCuadro(tank6, 100);
animo.sumaCuadro(tank7, 100);
animo.sumaCuadro(tank8, 100);
animo.sumaCuadro(tank9, 100);
animo.sumaCuadro(tank10, 100);
animo.sumaCuadro(tank11, 100);
animo.sumaCuadro(tank12, 100);
animo.sumaCuadro(tank13, 100);
animo.sumaCuadro(tank14, 100);
animo.sumaCuadro(tank15, 100);
animo.sumaCuadro(tank16, 100);
animo.sumaCuadro(tank17, 100);
animo.sumaCuadro(tank18, 100);
animo.sumaCuadro(tank19, 100);
animo.sumaCuadro(tank20, 100);
animo.sumaCuadro(tank21, 100);
animo.sumaCuadro(tank22, 100);
animo.sumaCuadro(tank23, 100);
animo.sumaCuadro(tank24, 100);
animo.sumaCuadro(tank25, 100);
animo.sumaCuadro(tank26, 100);
animo.sumaCuadro(tank27, 100);
animo.sumaCuadro(tank28, 100);
animo.sumaCuadro(tank29, 100);
animo.sumaCuadro(tank30, 100);
animo.sumaCuadro(tank31, 100);
} |
d18cafd8-8b60-41da-9cf0-20b78360b1f3 | public static String getPAUSADO() {
return PAUSADO;
} |
354a5be3-3731-4ab3-9e77-a3c71b229804 | public static String getDESAPARECE() {
return DESAPARECE;
} |
c36354fd-ab43-496a-884a-1eb5a1aa6f99 | public static void main(String[] args) {
new ContatoJFrame().setVisible(true);
} |
274fec7f-2172-438c-93de-4c5330105b45 | public ContatoJFrame() {
initComponents();
listaPessoas = new Agenda();
} |
f574d772-cf95-4dbb-9ed2-b6d939a6edf6 | @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
nome = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
telefone = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Monospaced", 0, 18)); // NOI18N
jLabel1.setText("Adicionar contato:");
jLabel2.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel2.setText("Nome:");
nome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nomeActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jLabel3.setText("Telefone:");
telefone.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
telefoneActionPerformed(evt);
}
});
jButton1.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jButton1.setText("OK");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
jButton2.setText("Cancelar");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(0, 154, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(nome)
.addComponent(telefone)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(telefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents |
b39cde84-f82e-4d43-9a23-5702fda307d2 | public void actionPerformed(java.awt.event.ActionEvent evt) {
nomeActionPerformed(evt);
} |
6404c5a6-1936-4c44-aa99-725f737e10ed | public void actionPerformed(java.awt.event.ActionEvent evt) {
telefoneActionPerformed(evt);
} |
0f35af05-b4c8-4209-8004-77929ea65c8c | public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
} |
636d2d37-5681-4234-a683-60c1a409c235 | public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
} |
b6a590d9-67fe-4463-b4af-bf8cb4555dfb | private void nomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nomeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_nomeActionPerformed |
12075ee3-a726-4801-8540-495dcddab321 | private void telefoneActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_telefoneActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_telefoneActionPerformed |
ae4a8735-605b-41f4-ab74-b3c47efe61c9 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
Pessoa contato = new Pessoa(nome.getText());
contato.setTelefone(telefone.getText());
JOptionPane.showMessageDialog(rootPane, listaPessoas.adicionarContato(contato));
//limpar tela;
nome.setText("");
telefone.setText("");
}//GEN-LAST:event_jButton1ActionPerformed |
63f9aa63-6a93-47bd-863f-9b64183334e8 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
System.exit(0);
}//GEN-LAST:event_jButton2ActionPerformed |
650b5636-400b-4b18-b748-f3268250af40 | 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.
* 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(ContatoJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ContatoJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ContatoJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ContatoJFrame.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 ContatoJFrame().setVisible(true);
}
});
} |
64beb1a8-1c8c-4bb6-a04f-2029d588eafb | public void run() {
new ContatoJFrame().setVisible(true);
} |
f137a638-16c8-47c0-997e-73555b51208b | public PessoaJuridica(String nome, String cnpj) {
super(nome);
this.cnpj = cnpj;
} |
35fe853e-ad5d-493b-b1ef-5e8f444d4e0b | public PessoaJuridica(String nome){
super(nome);
} |
7eb7bae1-f8fb-4360-8049-7c711e18af7c | public String getRazaoSocial() {
return razaoSocial;
} |
dd93f499-5138-479f-9354-69856a3fd89f | public void setRazaoSocial(String razaoSocial) {
this.razaoSocial = razaoSocial;
} |
a4b4fd01-35ff-4a21-a368-fadc64a2acef | public String getCnpj() {
return cnpj;
} |
62316044-0fc2-45fe-ae15-48ab4f2f66f2 | public void setCnpj(String cnpj) {
this.cnpj = cnpj;
} |
2c60aa5a-b326-4c55-b628-eb1aa2766ba0 | public Pessoa(String nome) {
this.nome = nome;
} |
5c457d58-69a0-4fe8-9bb3-c2dffa4c4322 | public String getNome() {
return nome;
} |
551761d0-cd57-4168-8895-2a94b626b26e | public void setNome(String nome) {
this.nome = nome;
} |
5a91330c-29f5-44d9-b0fe-ab6df8ca7ce4 | public String getTelefone() {
return telefone;
} |
6366ced7-3eaa-4267-aafb-85b0da463079 | public void setTelefone(String telefone) {
this.telefone = telefone;
} |
234951cb-47c7-41d2-8d7c-a9f7273a15fa | public String getEmail() {
return email;
} |
84855d7a-c93b-4d56-b62d-038668c49c6d | public void setEmail(String email) {
this.email = email;
} |
1148c7d0-4dee-49ec-8f6b-db75c2a816f1 | public String getEndereco() {
return endereco;
} |
d75261ee-d2b7-4bb2-9144-6dc893d9bb39 | public void setEndereco(String endereco) {
this.endereco = endereco;
} |
fac312c6-ce9f-4db4-a3b3-1bc7e5006f8d | public PessoaFisica(String nome) {
super(nome);
} |
2b052084-7ca5-4cd5-8ede-8a82850cac1c | public PessoaFisica(String nome, String cpf) {
super(nome);
this.cpf = cpf;
} |
2145af40-6911-47c2-a611-0e8cea15e9f7 | public String getCpf() {
return cpf;
} |
d05d61c1-fc56-452b-9582-d0a88bb27747 | public void setCpf(String cpf) {
this.cpf = cpf;
} |
904bfc34-ae31-4d3e-afca-cc224bd90ecf | public Agenda() {
this.listaContatos = new Vector();
} |
a65a31f7-db74-4b3d-af1d-f71c7608ba35 | public String adicionarContato(Pessoa pessoa) {
listaContatos.add(pessoa);
return "Contato adicionado com sucesso";
} |
da3cabb4-4a79-4c05-a1f2-3ebe6c513532 | public Vector getListaContatos() {
return listaContatos;
} |
909bfa32-3bad-4cbe-ac26-77afb17dbce4 | @RequestMapping(value = "/new", method = RequestMethod.POST, produces = "application/json")
@ResponseBody
public User getAsJSON(@ModelAttribute User user) {
return user;
} |
d5470540-df53-4ec7-a782-7cae5c8fa98f | @RequestMapping(method = RequestMethod.GET)
public ModelAndView showSampleForm() {
return new ModelAndView("content_sample", "user", new User());
} |
70041c23-5f43-4c7a-bbb8-f154c0c473d4 | public User() {
super();
} |
1cebf0f9-a1d8-4319-82eb-3091303257df | public User(String username, String password, String name, String lastName) {
super();
this.username = username;
this.password = password;
this.name = name;
this.lastName = lastName;
} |
a5b4b62d-8daa-4b45-98d5-9efdc1442959 | public String getLastName() {
return lastName;
} |
40eb15e0-6634-4749-bdde-4be537aca140 | public String getName() {
return name;
} |
5b986880-2164-43f1-b62d-69fdc9448ca6 | public String getPassword() {
return password;
} |
99bd8632-85c9-4dd0-9ae0-c0f44d1baaf2 | public String getUsername() {
return username;
} |
c2a3a003-9499-45b9-aadd-fe6c67c6f8cf | public void setLastName(String lastName) {
this.lastName = lastName;
} |
bd735981-73de-467d-8b48-23cc3995d424 | public void setName(String name) {
this.name = name;
} |
5e9176c8-4134-4112-b9df-6e47827c00d1 | public void setPassword(String password) {
this.password = password;
} |
1510b223-2a27-4b6c-bb7e-5694870c4fba | public void setUsername(String username) {
this.username = username;
} |
8616294c-c3f6-4e61-918f-86ef37836fa7 | @Transformer
public Message<?> transform(ErrorMessage errorMessage) {
MessagingException payload = (MessagingException) errorMessage.getPayload();
return payload.getFailedMessage();
} |
d02e61e8-3b2f-452e-98c8-f61310a32433 | public LastWindow(String title, Transaction last){
super(title);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.last = last;
this.initialize();
this.pack();
lastWindow = this;
} |
53ca8e63-c640-4ee3-b582-cdf819709541 | public void initialize(){
content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
this.setContentPane(content);
titleLabel = new JLabel("Your Last Transaction:");
content.add(titleLabel);
datePanel = new JPanel(new FlowLayout());
dateLabel = new JLabel("Date: " + last.getDate().toString());
datePanel.add(dateLabel);
content.add(datePanel);
amountPanel = new JPanel(new FlowLayout());
amountLabel = new JLabel("Amount: $" + last.getAmount());
amountPanel.add(amountLabel);
content.add(amountPanel);
descriptionPanel = new JPanel(new FlowLayout());
descriptionLabel = new JLabel("Description: " + last.getDescription());
descriptionPanel.add(descriptionLabel);
content.add(descriptionPanel);
okButton = new JButton("OK");
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
lastWindow.dispose();
}
});
content.add(okButton);
} |
0e12d4b5-f02b-4701-9e73-888372946bcd | public void actionPerformed(ActionEvent e){
lastWindow.dispose();
} |
a73f056b-9f22-42de-9d84-6cae09216399 | public BalanceWindow(String title, double balance){
super(title);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.balance = balance;
System.out.println(balance);
this.initialize();
this.pack();
balanceWindow = this;
} |
5a97dcff-492b-476b-b65e-49d843370204 | public void initialize(){
content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
this.setContentPane(content);
titleLabel = new JLabel("Check Balance");
content.add(titleLabel);
amountPanel = new JPanel(new FlowLayout());
amountLabel = new JLabel("Current Balance: $" + balance);
amountPanel.add(amountLabel);
content.add(amountPanel);
okButton = new JButton("OK");
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
balanceWindow.dispose();
}
});
content.add(okButton);
} |
83e5cd40-4d45-435e-94c3-31e9e03a6d38 | public void actionPerformed(ActionEvent e){
balanceWindow.dispose();
} |
81dd791b-a034-41ed-9c32-03ae6827c222 | public Transaction(char type, Date date, double amount, String description){
this.type = type;
this.date = date;
this.amount = amount;
this.description = description;
} |
c96995de-a95b-4f7e-9e9a-c2a225ca7dfd | public Transaction(){
this.type = 'e';
this.date = new Date(0);
this.amount = 0;
this.description = "";
} |
9794cb8b-6129-4d99-9e19-6e2bbcd4c4d4 | public char getType(){
return type;
} |
bbf8dfac-198b-478d-aaa4-a3a3816e9d4c | public Date getDate(){
return date;
} |
63c81146-d3e1-4dad-a2c5-bc941a216a47 | public double getAmount(){
return amount;
} |
ab69fcd4-3aea-4494-b15a-d753e2c07a40 | public String getDescription(){
return description;
} |
4f68e32f-1f6c-4133-b25e-06727b338d73 | public TransactionWindow(String title, char type, BankBookDB db){
super(title);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.type = type;
if(type == 'd')
typeString = "Deposit";
else if (type == 'w')
typeString = "Withdraw";
this.initialize();
this.pack();
this.transWin = this;
bookdb = db;
} |
2e598f2c-c1e1-4aeb-a852-ed66a893551c | public void initialize(){
content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
this.setContentPane(content);
//Title
titleLabel = new JLabel(typeString);
titleLabel.setAlignmentX(CENTER_ALIGNMENT);
//Date Panel
datePanel = new JPanel(new FlowLayout());
dateLabel = new JLabel(dateString);
datePanel.add(dateLabel);
monthOptions = new ArrayList<Integer>();
for(int i=1;i<=12;i++)
monthOptions.add(Integer.valueOf(i));
Integer monthArray[] = new Integer[12];
monthArray = monthOptions.toArray(monthArray);
monthBox = new JComboBox<Integer>(monthArray);
datePanel.add(monthBox);
datePanel.add(new JLabel("/"));
//Static days field for now
dayOptions = new ArrayList<Integer>();
for(int i=1;i<=31;i++)
dayOptions.add(Integer.valueOf(i));
Integer daysArray[] = new Integer[31];
daysArray = dayOptions.toArray(daysArray);
dayBox = new JComboBox<Integer>(daysArray);
datePanel.add(dayBox);
datePanel.add(new JLabel("/"));
//this probably shouldn't be hard coded, will change later (See: Y2K)
yearOptions = new ArrayList<Integer>();
for(int i=1950;i<=2050;i++)
yearOptions.add(Integer.valueOf(i));
Integer[] yearsArray = new Integer[50];
yearsArray = yearOptions.toArray(yearsArray);
yearBox = new JComboBox<Integer>(yearsArray);
datePanel.add(yearBox);
//Amount Panel
amountPanel = new JPanel();
amountPanel.setLayout(new FlowLayout());
amountLabel = new JLabel(amountString );
amountFormat = NumberFormat.getCurrencyInstance();
amountField = new JFormattedTextField(amountFormat);
amountField.setValue(new Double(0.00));
amountField.setColumns(10);
amountPanel.add(amountLabel);
amountPanel.add(amountField);
//Description Panel
descriptionPanel = new JPanel();
descriptionPanel.setLayout(new FlowLayout());
descriptionLabel = new JLabel(descriptionString);
descriptionField = new JTextField(40);
descriptionPanel.add(descriptionLabel);
descriptionPanel.add(descriptionField);
//Buttons Panel
//No event listeners yet
buttonsPanel = new JPanel(new FlowLayout());
okButton = new JButton("OK");
okButton.addActionListener(new ActionListener(){
private double amount;
private Date date;
private String description, month, day, year;
public void actionPerformed(ActionEvent e){
month = monthBox.getSelectedItem().toString();
day = dayBox.getSelectedItem().toString();
year = yearBox.getSelectedItem().toString();
date = Date.valueOf(year + "-" + month + "-" + day);
description = descriptionField.getText();
try{
amountField.commitEdit();
}
catch(Exception ex){
ex.printStackTrace();
}
Double amountHolder = Double.parseDouble(amountField.getValue().toString());
amount = amountHolder.doubleValue();
bookdb.transaction(date, amount, description, type);
transWin.dispose();
}
});
buttonsPanel.add(okButton);
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
transWin.dispose();
}
});
buttonsPanel.add(cancelButton);
//Add panels to content
content.add(titleLabel);
content.add(datePanel);
content.add(amountPanel);
content.add(descriptionPanel);
content.add(buttonsPanel);
} |
fe3dee7d-762a-48ff-b096-c844903bb557 | public void actionPerformed(ActionEvent e){
month = monthBox.getSelectedItem().toString();
day = dayBox.getSelectedItem().toString();
year = yearBox.getSelectedItem().toString();
date = Date.valueOf(year + "-" + month + "-" + day);
description = descriptionField.getText();
try{
amountField.commitEdit();
}
catch(Exception ex){
ex.printStackTrace();
}
Double amountHolder = Double.parseDouble(amountField.getValue().toString());
amount = amountHolder.doubleValue();
bookdb.transaction(date, amount, description, type);
transWin.dispose();
} |
9d6fac4d-12e9-430d-89b4-aee0c32426fe | public void actionPerformed(ActionEvent e){
transWin.dispose();
} |
9cd0cda1-1eeb-472b-9663-c7b0466d04a1 | public int getDays(String month){
String[] evenMonths = {"April" , "June", "September", "November"};
String[] oddMonths = {"January", "March", "May", "July", "August", "October", "December"};
if(month.equalsIgnoreCase("February"))
return 29;
for(String s: evenMonths){
if(s.equalsIgnoreCase(month))
return 30;
}
for(String s: oddMonths){
if(s.equalsIgnoreCase(month))
return 31;
}
//Return 0 if no match
return 0;
} |
660b2256-92d0-4860-9b1e-64f8a74829e6 | BankBookDB(String user, String password,String serverName, String dbName){
properties = new Properties();
properties.put("user", user);
properties.put("password", password);
try{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + serverName + ":3306/" + dbName, properties);
} catch (Exception e){
e.printStackTrace();
}
} |
aa03de7d-b73c-456b-91bc-224f83b50830 | public double getBalance(){
try {
Statement statement = connection.createStatement();
ResultSet result;
double sum;
String query = "SELECT SUM(AMOUNT) FROM transactions";
result = statement.executeQuery(query);
result.next();
sum = result.getDouble("SUM(AMOUNT)");
if(statement!= null)
statement.close();
return sum;
} catch (SQLException e) {
e.printStackTrace();
return 0;
}
} |
889a5bc6-306b-4611-8a95-14cea2a35d57 | public Transaction getLast() throws SQLException{
Statement statement = null;
try{
char lastType = 'e';
double amount = 0.0;
Date date = new Date(0);
String description = new String();
statement = connection.createStatement();
ResultSet result;
String query = "SELECT date,description,amount FROM transactions ORDER BY date DESC LIMIT 1";
result = statement.executeQuery(query);
while(result.next()){
amount = result.getDouble("amount");
date = result.getDate("date");
description = result.getString("description");
}
if(amount < 0.0)
lastType = 'w';
else
lastType = 'd';
return new Transaction(lastType,date ,amount,description);
}
catch(SQLException e) {
e.printStackTrace();
return new Transaction();
}
finally{
if(statement!= null)
statement.close();
}
} |
13963332-7d27-41f9-922f-9e74ee864a6f | public void transaction(Date date, double amount, String description, char type){
try{
if(type == 'w')
amount = -amount;
Statement statement = connection.createStatement();
String query = "INSERT INTO transactions (date,amount,description) VALUES ('" + date.toString() + "','" + amount + "','" + description + "')";
statement.executeUpdate(query);
statement.close();
} catch(SQLException e){
e.printStackTrace();
}
} |
a16079a4-73d2-4b67-abff-a4d1a1eb4f60 | public BankBookGUI(String title, BankBookDB db, double balance, Transaction last){
super(title);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.initialize();
this.pack();
this.setVisible(true);
bankbook = this;
this.db = db;
this.balance = balance;
this.last = last;
} |
bd9896e2-13ce-4983-bef7-f8b1581d3686 | public void initialize(){
content = new JPanel();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
this.setContentPane(content);
titleLabel = new JLabel("Bank Book Manager");
authorLabel = new JLabel(authorString);
depositButton = new JButton("Deposit");
depositButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
TransactionWindow depositWindow = new TransactionWindow("New Deposit",'d', db);
depositWindow.setVisible(true);
}
});
withdrawButton = new JButton("Withdraw");
withdrawButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
TransactionWindow withdrawWindow = new TransactionWindow("New Withdrawal",'w', db);
withdrawWindow.setVisible(true);
}
});
balanceButton = new JButton("Check Balance");
balanceButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
BalanceWindow balanceWindow = new BalanceWindow("Current Balance", db.getBalance());
balanceWindow.setVisible(true);
}
});
lastButton = new JButton("Last Transaction");
lastButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
Transaction lastTrans;
try{
lastTrans = db.getLast();
LastWindow lastWindow = new LastWindow("Last Transaction", lastTrans);
lastWindow.setVisible(true);
} catch(SQLException e){
e.printStackTrace();
System.exit(0);
}
}
});
quitButton = new JButton("Quit");
quitButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
bankbook.dispose();
}
});
content.add(titleLabel);
content.add(authorLabel);
content.add(depositButton);
content.add(withdrawButton);
content.add(balanceButton);
content.add(lastButton);
content.add(quitButton);
} |
eba83356-b2ac-4118-bd10-6b81678f921b | public void actionPerformed(ActionEvent event){
TransactionWindow depositWindow = new TransactionWindow("New Deposit",'d', db);
depositWindow.setVisible(true);
} |
8d984f77-8f19-47f9-a8f4-fc145097ea56 | public void actionPerformed(ActionEvent event){
TransactionWindow withdrawWindow = new TransactionWindow("New Withdrawal",'w', db);
withdrawWindow.setVisible(true);
} |
c2a91a5b-24dc-4a6d-914e-4c70091913a1 | public void actionPerformed(ActionEvent event){
BalanceWindow balanceWindow = new BalanceWindow("Current Balance", db.getBalance());
balanceWindow.setVisible(true);
} |
8c58b3c2-29ce-4f13-9da5-a75067cd2a49 | public void actionPerformed(ActionEvent event){
Transaction lastTrans;
try{
lastTrans = db.getLast();
LastWindow lastWindow = new LastWindow("Last Transaction", lastTrans);
lastWindow.setVisible(true);
} catch(SQLException e){
e.printStackTrace();
System.exit(0);
}
} |
3312eb1a-0aa1-4a5a-8b8d-769de2e9b826 | public void actionPerformed(ActionEvent event){
bankbook.dispose();
} |
f8bf6062-626f-465d-975c-db144b8a3d56 | public BankBook()
{
db = new BankBookDB("user","test","localhost", "bankbook");
this.loadData();
mainWindow = new BankBookGUI("Bank Book Manager" ,db, balance, last);
try {
this.last = db.getLast();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.balance = db.getBalance();
} |
ce979eeb-0c3e-49bd-a475-66f63b606129 | public double getBalance(){
balance = db.getBalance();
return balance;
} |
1a6efa17-48ee-4ef0-be40-a1eabcb074ec | public void deposit(Date date, double amount, String description){
db.transaction(date,amount,description,'d');
this.balance = db.getBalance();
try {
this.last = db.getLast();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
24578bfc-0b7c-469d-8e06-8e575c33bfa1 | public void withdraw(Date date, double amount, String description){
db.transaction(date,amount,description,'w');
this.balance = db.getBalance();
try {
this.last = db.getLast();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
16423b3e-da62-43ba-a6bd-b89b294fb500 | public Transaction getLast(){
try{
this.last = db.getLast();
}
catch (SQLException e){
e.printStackTrace();
}
return this.last;
} |
30670604-716d-4ebd-9986-41637f68b2fc | public void loadData(){
try{
balance = db.getBalance();
last = db.getLast();
}
catch(Exception e){
e.printStackTrace();
}
} |
8a0f616c-453a-448a-9608-8528e223d5cd | public static void main(String[] args){
BankBook bankbook = new BankBook();
} |
c82dce52-3c3c-423a-8f65-077011db6498 | E save(E entity); |
3b8bb804-eed4-41ed-a2ec-d4654ea7e47d | void delete(E entity); |
388a622b-3367-4ab8-a6b9-fcdd17dfa746 | E findById(K id); |
af860edf-9329-471a-a0e1-abc05c6af074 | public List<Employee> getEmployeesByName(Name name); |
d6ed9a59-59dd-4130-868d-add2e38d380a | @Override
public List<Employee> getEmployeesByName(Name name) {
Query namedQuery = getEntityManager().createNamedQuery("getEmployeeByName");
List<Employee> empList = namedQuery.getResultList();
return empList;
} |
bb063cf3-bfc0-4434-a5e7-0496fa7c1946 | public AbstractJpaDaoImpl() {
ParameterizedType genericType = (ParameterizedType) getClass().getGenericSuperclass();
this.entityClass = (Class<E>) genericType.getActualTypeArguments()[1];
} |
78b46452-8f49-47dd-9efb-294e2617a925 | public EntityManager getEntityManager() {
return entityManager;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.