Experiments VI Experiments fourteen

Sixth experiment

package of bank accounts;
the Account class public
{
 Private String acnumber; // account
 private String name; // depositor's name
 private String khtime; // Opening time
 private String accId; // ID number
 private double money; // balance of deposits
 private double Cmoney; // deposit money
 private double Qmoney; // withdrawn money
    
    public the Account (acnumber String, String name, String khtime, String ACCID, money Double, Double Cmoney, Double Qmoney) {
        this.acnumber = acnumber;
        this.name = name;
        = khtime this.khtime;
     this.accId = ACCID;
        this.money = Money;
        this.Cmoney = Cmoney;
        this.Qmoney = Qmoney;
    } // constructor initializes
 public void cunkuan ()
 IF {(Cmoney <= 0) {
        System.out.println ( "amount of the deposit must be greater than 0");}
 the else
  this.money + = Cmoney;
    System.out.println ( "deposit has been successful!");
    The System.out. println ( "the deposit balance is:" + this.money); 
 } // teller
 public Double qukuan ()
 {IF (Qmoney <= 0) {
        System.out.println ( "withdrawal amount must be greater than 0");
        return 0;
    }
    IF (this.money <= Qmoney) {
        System.out.println ( "insufficient funds, not withdrawal");
        return 0;
    }
    the else
     this.money - = Qmoney;
    System.out.println ( "withdrawal success! ");
    System.out.println (" balance after withdrawal is: "+ this.money);
    return Money;
  
 } // Withdrawal
 void chaxun public ()
 {
  System.out.println ( "Query success!");
  System.out.println ( "account balance" + this.money);
 } // query
 public void the Finalize ()
 {
  System.out. the println ( "Called destructor.!");
 } // destructor release space
 public static void main (String [] args) {
  the Account A1 = the Account new new ( "3,485,658", "the Dali", "2019-4-11" , "123456789", 2500,4565,5878);
  a1.cunkuan ();
  a1.qukuan ();
  a1.chaxun ();
  a1.finalize ();
  
 }
}
The results are as follows:

Experimental experience:

1.Java in object-oriented class encapsulating core features, is thought specific implementation information hiding technology, and the feeling in C ++ classes encapsulated many similarities.

2. The procedure to get a start, no start, after careful thought, nothing more than the private banking clients of information hiding, then there are operations on the money, and take on deposit.

3. This program should also take into account the money deposited is greater than zero, the money in the account is greater than the money taken. 

 

 

Experimental fourteen

Test Countdown;

* in java.awt Import;.
Import java.awt.event.ActionEvent The;
Import java.awt.event.ActionListener;
Import in javax.swing *;.
public class CountDown the extends the JFrame {
the JButton jButton;
the JLabel JLabel;
int Time = 60;
public countDown () {
FlowLayout FL = new new FlowLayout (FlowLayout.CENTER);
this.setLayout (FL);
// add listener for the button jButton achieve the countdown resumes when you click
jButton = new JButton ( "restart");
jButton. the addActionListener (the ActionListener new new () {
@Override
public void the actionPerformed (the ActionEvent the arg0) {
Dispose (); // Close the current window
new CountDown (); // Create a window
}

});
// Create a thread anonymous inner classes to implement the countdown time, which is the core of the entire code
JLabel new new = the JLabel ();
new new the Thread () {
public void RUN () {
the while (Time> 0) {
Time- -;
{// flash when red when time reaches 5 seconds iF (time <. 6)
jLabel.setForeground (Color.RED);
}
jLabel.setText (time + "s");
the try {
the Thread.sleep (1000);
} the catch (InterruptedException E) {
e.printStackTrace ();
}
}
}

}.start();

this.add(jButton);
this.add(jLabel);
this.setTitle("倒计时");
this.setSize(300, 200);
this.setResizable(true);
this.setVisible(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}

public static void main(String[] args) {
new CountDown();

}

}

Experience have to continue efforts

Guess you like

Origin www.cnblogs.com/Java199-zengtai/p/11111062.html