|
| 1 | +package models; |
| 2 | + |
| 3 | +import java.util.Scanner; |
| 4 | + |
| 5 | +public class Sach { |
| 6 | + private String maSach; |
| 7 | + private String ngayNhap; |
| 8 | + private int donGia; |
| 9 | + private int soLuong; |
| 10 | + |
| 11 | + |
| 12 | + public Sach() { |
| 13 | + this.maSach = ""; |
| 14 | + this.ngayNhap = ""; |
| 15 | + this.donGia = 0; |
| 16 | + this.soLuong = 0; |
| 17 | + } |
| 18 | + |
| 19 | + public Sach(String maSach, String ngayNhap, int donGia, int soLuong) { |
| 20 | + this.maSach = maSach; |
| 21 | + this.ngayNhap = ngayNhap; |
| 22 | + this.donGia = donGia; |
| 23 | + this.soLuong = soLuong; |
| 24 | + } |
| 25 | + |
| 26 | + public void input() { |
| 27 | + Scanner sc = new Scanner(System.in); |
| 28 | + |
| 29 | + System.out.print("Nhập mã sách: "); |
| 30 | + this.maSach = sc.nextLine(); |
| 31 | + |
| 32 | + System.out.print("Nhập ngày nhập: "); |
| 33 | + this.ngayNhap = sc.nextLine(); |
| 34 | + |
| 35 | + System.out.print("Nhập đơn giá: "); |
| 36 | + this.donGia = sc.nextInt(); |
| 37 | + |
| 38 | + System.out.print("Nhập số lượng: "); |
| 39 | + this.soLuong = sc.nextInt(); |
| 40 | + |
| 41 | + } |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + @Override |
| 46 | + public String toString() { |
| 47 | + return "Sach [maSach=" + maSach + ", ngayNhap=" + ngayNhap + ", donGia=" + donGia + ", soLuong=" + soLuong |
| 48 | + + "]"; |
| 49 | + } |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + public String getMaSach() { |
| 54 | + return maSach; |
| 55 | + } |
| 56 | + |
| 57 | + public void setMaSach(String maSach) { |
| 58 | + this.maSach = maSach; |
| 59 | + } |
| 60 | + |
| 61 | + public String getNgayNhap() { |
| 62 | + return ngayNhap; |
| 63 | + } |
| 64 | + |
| 65 | + public void setNgayNhap(String ngayNhap) { |
| 66 | + this.ngayNhap = ngayNhap; |
| 67 | + } |
| 68 | + |
| 69 | + public int getDonGia() { |
| 70 | + return donGia; |
| 71 | + } |
| 72 | + |
| 73 | + public void setDonGia(int donGia) { |
| 74 | + this.donGia = donGia; |
| 75 | + } |
| 76 | + |
| 77 | + public int getSoLuong() { |
| 78 | + return soLuong; |
| 79 | + } |
| 80 | + |
| 81 | + public void setSoLuong(int soLuong) { |
| 82 | + this.soLuong = soLuong; |
| 83 | + } |
| 84 | +} |
0 commit comments