Description The Face Pay is a program based on Facebook App. The program includes money transfer, balance inquiry, and virtual cards. The money transfer section includes bank information import and safety confirmation. Virtual cards allow daily cards (i.e., membership card, bus card, etc.) to be virtualized. For detailed explanation, refer to the attached PowerPoint.

Codes Part 1: package coding;

import java.awt.EventQueue;

import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JButton; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel;

import java.awt.event.ActionListener; import java.awt.event.ActionEvent;

public class Layout {

private JFrame frmFacePay;
private JTextField txtTypeName;
private JTextField txtTypeName_1;
public static double amount = 0;
public static String name1;
public static String name2;

/**
 * Launch the application.
 */
public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {
        public void run() {

            try {
                Layout window = new Layout();
                window.frmFacePay.setVisible(true);

            } catch (Exception e) {
                e.printStackTrace();
            }

        }
    });

}

/**
 * Create the application.
 */
public Layout() {
    initialize();
}

/**
 * Initialize the contents of the frame.
 */
@SuppressWarnings("deprecation")
private void initialize() {
    frmFacePay = new JFrame();
    frmFacePay.setAlwaysOnTop(true);
    frmFacePay.setResizable(false);
    frmFacePay.setTitle("Face Pay");
    frmFacePay.setBounds(100, 100, 287, 168);
    frmFacePay.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frmFacePay.getContentPane().setLayout(null);

    JLabel lblNewLabel = new JLabel("Transfter Amount: CAD$");
    lblNewLabel.setBounds(10, 10, 150, 20);
    frmFacePay.getContentPane().add(lblNewLabel);

    JLabel lblNewLabel_1 = new JLabel("Transfer From:");
    lblNewLabel_1.setBounds(10, 40, 100, 20);
    frmFacePay.getContentPane().add(lblNewLabel_1);

    JLabel lblNewLabel_2 = new JLabel("Transfer To:");
    lblNewLabel_2.setBounds(10, 70, 100, 20);
    frmFacePay.getContentPane().add(lblNewLabel_2);

    txtTypeName = new JTextField();
    txtTypeName.setText("Type Name");
    txtTypeName.setBounds(160, 40, 100, 20);
    frmFacePay.getContentPane().add(txtTypeName);
    txtTypeName.setColumns(10);

    txtTypeName_1 = new JTextField();
    txtTypeName_1.setText("Type Name");
    txtTypeName_1.setBounds(160, 70, 100, 20);
    frmFacePay.getContentPane().add(txtTypeName_1);
    txtTypeName_1.setColumns(10);

    JSpinner spinner = new JSpinner();
    spinner.setModel(new SpinnerNumberModel(new Double(0), null, null, new Double(1)));
    spinner.setBounds(160, 10, 100, 20);
    frmFacePay.getContentPane().add(spinner);

    JButton btnNewButton = new JButton("Confirm");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            amount = (double) spinner.getValue();
            name1 = txtTypeName.getName();
            name2 = txtTypeName_1.getName();
            Transfer.run();
        }
    });
    btnNewButton.setBounds(10, 100, 250, 20);
    frmFacePay.getContentPane().add(btnNewButton);

}

}   Part 2: package coding;

import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter;

public class Transfer { static String name[] = new String[5]; static double balance[] = new double[5]; static File data = new File("TYPE YOUR DATA LOCATION HERE");

public static void load() {
    FileReader fr;
    try {
        fr = new FileReader(data);
        BufferedReader reader = new BufferedReader(fr);
        for (int i = 0; i < 5; i++) {
            name[i] = reader.readLine();
            balance[i] = Double.valueOf(reader.readLine());
        }
        reader.close();
        fr.close();
    } catch (NumberFormatException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

public static void run() {
    load();
    double amount = Layout.amount;
    String name1 = Layout.name1;
    String name2 = Layout.name2;
    for (int i = 0; i < 5; i++) {
        if (name1 == name[i]) {
            balance[i] = balance[i] - amount;
        }
        if (name2 == name[i]) {
            balance[i] = balance[i] + amount;
        }
    }
    save();
}

public static void save() {
    PrintWriter writer = null;
    try {
        writer = new PrintWriter(data);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    for (int i = 0; i < 5; i++) {
        writer.println(name[i]);
        writer.println(balance[i]);
    }
}

}

Built With

Share this project:

Updates