Student Number: 231444416 Surname: BOTENDE Subject Code: OOP216D Campus: Soshanguve South Group: D
Student Number: 231444416 Surname: BOTENDE Subject Code: OOP216D Campus: Soshanguve South Group: D
Surname: BOTENDE
Subject Code: OOP216D
Campus: SOSHANGUVE SOUTH
Group: D
Part 1:
Enter your UML class diagram in the space below.
botende.mmk
-parishionerName : String
-parishAccNo : String
-amountToDonate : double
+ParishDonation()
+ParishDonation(parishionerName,parishAccNo,amountToDonate)
+setParishionerName(String) : void
+setParishAccNo(String) : void
+setAmountToDonate(double) : void
+getParishionerName() : String
+getParishAccNo() : String
+getAmountToDonate() : double
+determineTotalAmount(double) : double
Paste the source code of your concrete class in the space below:
package botende.mmk;
import java.io.Serializable;
import javax.swing.JOptionPane;
/**
*
* @author lp
*/
public class ParishDonation implements Serializable {
private String parishionerName;
private String parishAccNo;
private double amountToDonate;
public ParishDonation() {
}
return total;
}
}
Part 2:
Make a screenshot of your GUI and paste it in the space below:
Paste the source code of the GUI class in the space below:
package botende.mmk;
import javax.swing.JOptionPane;
import java.util.*;
import java.io.*;
/**
*
* @author lp
*/
public class DonationGUI extends javax.swing.JFrame {
ArrayList<ParishDonation> donations;
/**
* Creates new form DonationGUI
*/
public DonationGUI() {
initComponents();
donations=new ArrayList<ParishDonation>();
populateArrayList();
}
public void populateArrayList(){
try{
FileInputStream theFile=new FileInputStream("Donations.txt");
ObjectInputStream inputFile=new ObjectInputStream(theFile);
boolean endOfTheFile=false;
while(!endOfTheFile){
try{
donations.add((ParishDonation)inputFile.readObject());
}
catch(EOFException e){
endOfTheFile=true;
}
catch(Exception f){
JOptionPane.showMessageDialog(null, f.getMessage());
}
}
inputFile.close();
}
catch(IOException e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
try{
FileOutputStream file= new FileOutputStream("Donations.txt");
ObjectOutputStream outputFile=new ObjectOutputStream(file);
for(int i=0;i<donations.size();i++){
outputFile.writeObject(donations.get(i));
}
outputFile.close();
}
}
/**
* 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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextField2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField2ActionPerformed(evt);
}
});
jTextField3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField3ActionPerformed(evt);
}
});
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
pack();
}// </editor-fold>
donations.add(donation);
saveDonationsToFile();
}
}
jTextArea1.append(input1+"\n"+"R"+input2+"\n"+input3+"\n");
}
/**
* @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.
* 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(DonationGUI.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DonationGUI.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DonationGUI.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DonationGUI.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
¬í sr botende.mmk.ParishDonation°Îˆ*uç D amountToDonateL
parishAccNot Ljava/lang/String;L parishionerNameq ~ xp@•@ t 12346655t Mariesq ~ @( t
111111t mmsq ~ @•@ t 12345566t Marie