final project q7

This commit is contained in:
2022-05-24 23:19:13 +08:00
parent 07ed06c619
commit d3cf0c7a7c
13 changed files with 534 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/*
* Author: CHEN Yongyuan (Walter) 1930006025 from OOP(1007)
* Date: 2022-04-25
*/
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ViewSimple extends JFrame implements ModelListener {
private Library m;
private ControllerSimple c;
private JLabel label;
public ViewSimple(Library m, ControllerSimple c) {
this.m = m;
this.c = c;
// window
this.setTitle("View Simple");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300, 200);
m.addListener(this);
// component
label = new JLabel("Total number of borrowed books: " + m.totalBorrowedBooks());
add(label);
// final
this.setVisible(true);
}
public void update() {
label.setText("Total number of borrowed books: " + m.totalBorrowedBooks());
}
}