News Ticker

Menu

Browsing "Older Posts"

Browsing Category "Java"

Giải Đề Thi Java - Lần 2

Thứ Năm, 5 tháng 7, 2018 / 1 Comment


Link download đề: Click Download
Link download project: Click Download

Kham Khảo
Class TaiLieu
import java.util.*;

public abstract class TaiLieu {

 private String MaSo, TenNhaSX;
 private int SoBanPhatHanh;
 
 public String getMaSo() {
  return MaSo;
 }
 public void setMaSo(String maSo) {
  MaSo = maSo;
 }
 public String getTenNhaSX() {
  return TenNhaSX;
 }
 public void setTenNhaSX(String tenNhaSX) {
  TenNhaSX = tenNhaSX;
 }
 public int getSoBanPhatHanh() {
  return SoBanPhatHanh;
 }
 public void setSoBanPhatHanh(int soBanPhatHanh) {
  SoBanPhatHanh = soBanPhatHanh;
 }
 
 public TaiLieu() {
  super();
 }
 
 public TaiLieu(String name, String maso, int so_ban_phat_hanh) {
  super();
  this.setTenNhaSX(name);
  this.setMaSo(maso);
  this.setSoBanPhatHanh(so_ban_phat_hanh);
 }
 
 public void NhapThongTin() {
  Scanner sc = new Scanner(System.in);
  
  System.out.print("Nhap Ten Nha San Xuat: ");
  String name = sc.nextLine();
  this.setTenNhaSX(name);
  
  System.out.print("Nhap Ma So: ");
  String ms = sc.nextLine();
  this.setMaSo(ms);
  
  System.out.print("Nhap So Ban Duoc Phat Hanh: ");
  int so_luong = sc.nextInt();
  this.setSoBanPhatHanh(so_luong);
 }
 
 public void XuatThongTin() {
  System.out.println("Ten Nha San Xuat: "+this.getTenNhaSX());
  System.out.println("Ma So Tai Lieu: "+this.getMaSo());
  System.out.println("So Ban Phat Hanh: "+this.getSoBanPhatHanh());
 }
 
}

Class Sach
import java.util.*;

public class Sach extends TaiLieu{

 private String TenTacGia;
 private int So_Trang;
 
 public String getTenTacGia() {
  return TenTacGia;
 }
 public void setTenTacGia(String tenTacGia) {
  TenTacGia = tenTacGia;
 }
 public int getSo_Trang() {
  return So_Trang;
 }
 public void setSo_Trang(int so_Trang) {
  So_Trang = so_Trang;
 }
 
 public Sach() {
  super();
 }
 
 public Sach(String name, String maso, int so_ban_phat_hanh, String tacgia, int trang) {
  super(name,maso,so_ban_phat_hanh);
  this.setTenTacGia(tacgia);
  this.setSo_Trang(trang);
 }
 
 public void NhapThongTin() {
  super.NhapThongTin();
  
  Scanner sc = new Scanner(System.in);
  
  System.out.print("Nhap Ten Tac Gia: ");
  String tg = sc.nextLine();
  this.setTenTacGia(tg);
  
  System.out.print("Nhap So Trang Cua Sach: ");
  int trg = sc.nextInt();
  this.setSo_Trang(trg);
 }
 
 public void XuatThongTin() {
  super.XuatThongTin();
  System.out.println("Ten Tac Gia: "+this.getTenTacGia());
  System.out.println("So Trang: "+this.getSo_Trang());
 }
 
}

Class TapChi
import java.util.Scanner;

public class TapChi extends TaiLieu{

 private int SoPhatHanh, NgayPhatHanh;

 public int getSoPhatHanh() {
  return SoPhatHanh;
 }

 public void setSoPhatHanh(int soPhatHanh) {
  SoPhatHanh = soPhatHanh;
 }

 public int getNgayPhatHanh() {
  return NgayPhatHanh;
 }

 public void setNgayPhatHanh(int ngayPhatHanh) {
  NgayPhatHanh = ngayPhatHanh;
 }
 
 public TapChi() {
  super();
 }
 
 public TapChi(String name, String maso, int so_ban_phat_hanh, int sophathanh, int ngay) {
  super(name,maso,so_ban_phat_hanh);
  this.setSoPhatHanh(sophathanh);
  this.setNgayPhatHanh(ngay);
 }
 
 public void NhapThongTin() {
  super.NhapThongTin();
  Scanner sc = new Scanner(System.in);
  
  System.out.print("Nhap So Phat Han: ");
  int sophathanh = sc.nextInt();
  this.setSoPhatHanh(sophathanh);
  
  System.out.print("Ngay Phat Hanh: ");
  int ngay = sc.nextInt();
  this.setNgayPhatHanh(ngay);
 }
 
 public void XuatThongTin() {
  super.XuatThongTin();
  System.out.println("So Phat Hanh: "+this.getSoPhatHanh());
  System.out.println("Ngay Phat Hanh: "+this.getNgayPhatHanh());
 }
}

Class DanhSachTaiLieu
import java.util.Scanner;

public class DanhSachTaiLieu {
public int total = 0;
 
 TaiLieu[] tailieu = new TaiLieu[100];
 
 void cheat() {
  for(int i=0; i<100; i++)
   tailieu[i] = new TaiLieu() {
   };
 }
 
 public void KiemTra(int key) {
  if(key == 1) {
   tailieu[total] = new Sach();
   Sach sach = new Sach();
   sach.NhapThongTin();
   tailieu[total] = sach;
   total++;
   
  }
  
  else if(key == 2) {
   tailieu[total] = new TapChi();
   TapChi tapchi = new TapChi();
   tapchi.NhapThongTin();
   tailieu[total] = tapchi;
   total++;
  }
  
  else if(key == 3) {
   for(int i=0; i<total; i++)
    tailieu[i].XuatThongTin();
    System.out.println();
  }
 }
 
 public void Search() {
  System.out.println();
  Scanner sc = new Scanner(System.in);
  System.out.print("Nhap Ten Nha San Xuat Can Tim: ");
  String search = sc.nextLine();
  
  for(int i=0; i<total; i++)
   if(tailieu[i].getTenNhaSX().equals(search) == true) tailieu[i].XuatThongTin();
  System.out.println();
 }
 
 public void TaiLieuPhatHanhNhieuNhat() {
  System.out.println();
  int max = tailieu[0].getSoBanPhatHanh();
  int max1 = 0;
  
  for(int i=1; i<total; i++)
   if(max < tailieu[i].getSoBanPhatHanh()) {
     max = tailieu[i].getSoBanPhatHanh();
     max1 = i;
   }
  
  tailieu[max1].XuatThongTin();
  System.out.println();
 }
 
}


Class Test Main
import java.util.Scanner;

public class TestMain {

 
 public static void main(String[] args) {
  DanhSachTaiLieu danhsach = new DanhSachTaiLieu();
  
  Scanner sc = new Scanner(System.in);
  int key;
  
  do
  {
   
  System.out.println("0. Thoat");
  System.out.println("1. Them Sach");
  System.out.println("2. Them Tap Chi");
  System.out.println("3. Hien Thi Danh Sach Tai Lieu");
  System.out.println("4. Tim Kiem Ten Nha Xuat Ban");
  System.out.println("5. Nguoi Co So Phat Hanh Nhieu Nhat");
  
  System.out.print("Ban Muon Chon: ");
  key = sc.nextInt();
  
  switch(key) {
  case 0: break;
  case 1: danhsach.KiemTra(key); break;
  case 2: danhsach.KiemTra(key); break;
  case 3: danhsach.KiemTra(key); break;
  case 4: danhsach.Search(); break;
  case 5: danhsach.TaiLieuPhatHanhNhieuNhat(); break;
  }
  }while(key != 0);
  
 }
}

Cách Import project Vào Eclipse

Chủ Nhật, 1 tháng 7, 2018 / No Comments
Nếu bạn vừa cài lại Eclipse mà trước đó đã có một số project được làm rồi bạn cần phải Import chúng lại mới có thể mở được.
File -> Import


Nhấn Next. Sau đó nhấn nút Browse để tìm đến thư mục chứa project.

import

Chọn Project cần import rồi nhấn Finish, chú ý khi chọn thư mục chứa các project bạn phải ấn OK chứ không được nháy đúp.

import

Giải Đề Thi Lập Trình Java 2018 - Bản Hoàn Chỉnh

/ No Comments


Link Download Đề: Click Download Đề
Link Download project: Click Down Project 
Bài Kham Khảo
Câu 1:
Class Khách Hàng
import java.util.Scanner;

public abstract class KhachHang {

 private String Name, Code, address;
 private float KW_Tieu_Thu, Don_Gia, Thanh_Tien;
 
 public String getName() {
  return Name;
 }
 public void setName(String name) {
  Name = name;
 }
 public String getCode() {
  return Code;
 }
 public void setCode(String code) {
  Code = code;
 }
 public String getAddress() {
  return address;
 }
 public void setAddress(String address) {
  this.address = address;
 }
 public float getKW_Tieu_Thu() {
  return KW_Tieu_Thu;
 }
 public void setKW_Tieu_Thu(float kW_Tieu_Thu) {
  KW_Tieu_Thu = kW_Tieu_Thu;
 }
 public float getDon_Gia() {
  return Don_Gia;
 }
 public void setDon_Gia(float don_Gia) {
  Don_Gia = don_Gia;
 }
 public float getThanh_Tien() {
  return Thanh_Tien;
 }
 public void setThanh_Tien(float thanh_Tien) {
  Thanh_Tien = thanh_Tien;
 }
 
 public KhachHang() {
  super();
 }
 
 public KhachHang(String name, String code, String address, float kw, float don_gia, float thanh_tien) {
  super();
  this.setName(name);
  this.setCode(code);
  this.setAddress(address);
  this.setKW_Tieu_Thu(kw);
  this.setDon_Gia(don_gia);
  this.setThanh_Tien(thanh_tien);
 }
 
 
 public void NhapThongTin() {
  Scanner sc = new Scanner(System.in);
  
  System.out.print("Nhập Tên Khách Hàng: ");
  String name = sc.nextLine();
  this.setName(name);
  
  System.out.print("Nhập Mã Số Khách Hàng: ");
  String code = sc.nextLine();
  this.setCode(code);
  
  System.out.print("Nhập Địa Chỉ Khách Hàng: ");
  String address = sc.nextLine();
  this.setAddress(address);
  
  System.out.print("Nhập Số KW Khách Đã Sử Dụng: ");
  float kw = sc.nextFloat();
  this.setKW_Tieu_Thu(kw);
  
  System.out.print("Nhập Đơn Giá: ");
  float don_gia = sc.nextFloat();
  this.setDon_Gia(don_gia);
  
 }
 
 public void XuatThongTin() {
  System.out.println("Tên Khách Hàng: "+this.getName());
  System.out.println("Mã Số Khách Hàng: "+this.getCode());
  System.out.println("Địa Chỉ Khách Hàng: "+this.getAddress());
  System.out.println("Số KW Khách Đã Sử Dụng: "+this.getKW_Tieu_Thu());
  System.out.println("Đơn Giá: "+this.getDon_Gia());
 }
 
}
Class Khách Việt Nam
import java.util.Scanner;

public class KhachHangVietNam extends KhachHang{

 private String Loai_Khach_hang;
 private float Dinh_Muc;
 
 public String getLoai_Khach_hang() {
  return Loai_Khach_hang;
 }
 public void setLoai_Khach_hang(String loai_Khach_hang) {
  Loai_Khach_hang = loai_Khach_hang;
 }
 public float getDinh_Muc() {
  return Dinh_Muc;
 }
 public void setDinh_Muc(float dinh_Muc) {
  Dinh_Muc = dinh_Muc;
 }
 
 public KhachHangVietNam() {
  super();
 }
 
 public KhachHangVietNam(String name, String code, String address, float kw, float don_gia, 
   float thanh_tien, String loai, float dinh_muc) {
  super(name,code,address,kw,don_gia,thanh_tien);
  this.setLoai_Khach_hang(loai);
  this.setDinh_Muc(dinh_muc);
 }
 
 public void NhapThongTin() {
 super.NhapThongTin();
 Scanner sc = new Scanner(System.in);
 
 System.out.print("Nhập Loại Khách Hàng: ");
 String loai = sc.nextLine();
 this.setLoai_Khach_hang(loai);
 
 System.out.print("Nhập Định Mức: ");
 float dinh_muc = sc.nextFloat();
 this.setDinh_Muc(dinh_muc);
 }
 
 public void TinhTien() {
  float tinhtien, vuoc_dinh_muc = this.getKW_Tieu_Thu() - this.getDinh_Muc();
  
  tinhtien = (this.getKW_Tieu_Thu() < this.getDinh_Muc()) ? (this.getKW_Tieu_Thu()*this.getDon_Gia()) : 
   ((this.getKW_Tieu_Thu()*this.getDon_Gia()*this.getDinh_Muc()) + (vuoc_dinh_muc * this.getDon_Gia() * (float) 2.5));
  this.setThanh_Tien(tinhtien);
 }
 
 public void XuatThongTin() {
  super.XuatThongTin();
  System.out.println("Loại Khách Hàng: "+this.getLoai_Khach_hang());
  System.out.println("Định Mức: "+this.getDinh_Muc());
  this.TinhTien();
  System.out.println("Thành Tiền: "+this.getThanh_Tien());
 }
}
Class Khách Nước Ngoài
import java.util.Scanner;

public class KhachHangNuocNgoai extends KhachHang{

 private String nationality;

 public String getNationality() {
  return nationality;
 }

 public void setNationality(String nationality) {
  this.nationality = nationality;
 }
 
 public KhachHangNuocNgoai() {
  super();
 }
 
 public KhachHangNuocNgoai(String name, String code, String address, float kw, float don_gia, float thanh_tien, String nationality) {
  super(name,code,address,kw,don_gia,thanh_tien);
  this.setNationality(nationality);
 }
 
 public void NhapThongTin() {
  super.NhapThongTin();
  Scanner sc = new Scanner(System.in);
  
  System.out.print("Nhập Quốc Tịch: ");
  String nationality = sc.nextLine();
  this.setNationality(nationality);
 }
 
 public void TinhTien() {
  this.setThanh_Tien(this.getKW_Tieu_Thu() * this.getDon_Gia());
 }
 
 public void XuatThongTin() {
  super.XuatThongTin();
  System.out.println("Quốc Tịch: "+this.getNationality());
  this.TinhTien();
  System.out.println("Thành Tiền: "+this.getThanh_Tien());
 }
}
Câu 3:
Class Danh Sách Khách Hàng



public class DanhSachKhachHang {

 int total = 0;
 
 KhachHang[] khachhang = new KhachHang[100];
 
 void cheat() {
  for(int i=0; i<100; i++)
   khachhang[i] = new KhachHang() {
   };
 }
 
 public void Check(int key) {
  if(key == 1) {
   khachhang[total] = new KhachHangVietNam();
   KhachHangVietNam viet = new KhachHangVietNam();
   viet.NhapThongTin();
   khachhang[total] = viet;
   total++;
  }
  
  else if(key == 2) {
   khachhang[total] = new KhachHangNuocNgoai();
   KhachHangNuocNgoai nuocngoai = new KhachHangNuocNgoai();
   nuocngoai.NhapThongTin();
   khachhang[total] = nuocngoai;
   total++;
  }
  
  else if(key == 3) {
   for(int i=0; i<total; i++) {
    khachhang[i].XuatThongTin();
    System.out.println();
   } 
  }
 }
 
 public void ThanhTienCaoNhat() {
  float max = khachhang[0].getThanh_Tien();
  int location = 0;
  
  for(int i=1; i<total; i++) {
   if(max < khachhang[i].getThanh_Tien()) {
    max = khachhang[i].getThanh_Tien();
    location = i;
   }
  }
  khachhang[location].XuatThongTin();
 }
 
 public void KhachSuDungKwCaoNhat() {
  int location = 0;
  float max = khachhang[0].getKW_Tieu_Thu();
  
  for(int i=1; i<total; i++) {
   if(max > khachhang[i].getKW_Tieu_Thu()) {
     max = khachhang[i].getKW_Tieu_Thu();
     location = i;
   }
  }
  khachhang[location].XuatThongTin();
 }
}
Câu 4:
Class Test Khách Hàng
import java.util.Scanner;

public class TestMain {

 public static void main(String[] args) {
  DanhSachKhachHang DanhSach = new DanhSachKhachHang();
  Scanner sc = new Scanner(System.in);
  
  int key;
  do {
   
  System.out.println("=========== MENU  =============");
  System.out.println("| 0. Exit Program             |");
  System.out.println("| 1. Nhập Danh Sách Việt Nam  |");
  System.out.println("| 2. Nhập Danh Sách Nước Ngoài|");
  System.out.println("| 3. Xuất Tất Cả Danh Sách    |");
  System.out.println("| 4. Khách Hàng Tiền Cao Nhất |");
  System.out.println("| 5. Khách Hàng KW Thấp Nhất  |");
  System.out.println("===============================");
  
  System.out.print("Bạn Muốn Chọn: "); key = sc.nextInt();
  System.out.println();
  
  
  switch(key) {
  case 1: DanhSach.Check(key); break;
  case 2: DanhSach.Check(key); break;
  case 3: DanhSach.Check(key); break;
  case 4: DanhSach.ThanhTienCaoNhat(); break;
  case 5: DanhSach.KhachSuDungKwCaoNhat(); break;
  }
  
  }while(key != 0);
  System.out.println("Đã Thoát Chương Trình!");
 }

}
Có thể xem thêm tại: Java Programming

Giải Đề Thi Lập Trình Java 2018 (kham khảo)

Thứ Bảy, 2 tháng 6, 2018 / No Comments


Link Download Đề: Click Download
Bài Kham Khảo
Câu 1:
Class Khách Hàng
// Code by Penguis
import java.util.Scanner;

public abstract class KhachHang {

private String MaSo, HoTen, DiaChi;
private float SoLuongKW, DonGia, ThanhTien;

public String getMaSo() {
return MaSo;
}
public void setMaSo(String maSo) {
MaSo = maSo;
}
public String getHoTen() {
return HoTen;
}
public void setHoTen(String hoTen) {
HoTen = hoTen;
}
public String getDiaChi() {
return DiaChi;
}
public void setDiaChi(String diaChi) {
DiaChi = diaChi;
}
public float getSoLuongKW() {
return SoLuongKW;
}
public void setSoLuongKW(float soLuongKW) {
SoLuongKW = soLuongKW;
}
public float getDonGia() {
return DonGia;
}
public void setDonGia(float donGia) {
DonGia = donGia;
}
public float getThanhTien() {
return ThanhTien;
}
public void setThanhTien(float thanhTien) {
ThanhTien = thanhTien;
}

public KhachHang() {
super();
}

public KhachHang(String ma_so, String ten_khach, String dia_chi,float so_kw,float don_gia, float thanh_tien) {
super();
this.setMaSo(ma_so);
this.setHoTen(ten_khach);
this.setDiaChi(dia_chi);
this.setSoLuongKW(so_kw);
this.setDonGia(don_gia);
this.setThanhTien(thanh_tien);
}

public void nhapThongTin() {
Scanner sc = new Scanner(System.in);
String maso, ten, diachi;
float so_kw, dongia,thanh_tien;

System.out.print("Nhập mã số khách hàng: ");
maso =sc.nextLine();
this.setMaSo(maso);

System.out.print("Nhập tên khách hàng: ");
ten = sc.nextLine();
this.setHoTen(ten);

System.out.print("Nhập địa chỉ khách hàng: ");
diachi = sc.nextLine();
this.setDiaChi(diachi);

System.out.print("Nhập số Kw khách hàng: ");
so_kw = sc.nextFloat();
this.setSoLuongKW(so_kw);

System.out.print("Nhập đơn giá khách hàng: ");
dongia = sc.nextFloat();
this.setDonGia(dongia);
}

public abstract float tinhTien();

public void xuatThongTin() {
System.out.println("Tên Khách hàng: "+this.getHoTen());
System.out.println("Mã số khách hàng: "+this.getMaSo());
System.out.println("Địa Chỉ khách hàng: "+this.getDiaChi());
System.out.println("Số KW đã tiêu thụ: "+this.getSoLuongKW());
System.out.println("Đơn giá: "+this.getDonGia());

}

}
Class Khách Việt Nam
//Code by Penguis
import java.util.*;
public class KhachHangVietNam extends KhachHang{

private String LoaiKhachHang;
private float DinhMuc;

public String getLoaiKhachHang() {
return LoaiKhachHang;
}
public void setLoaiKhachHang(String loaiKhachHang) {
LoaiKhachHang = loaiKhachHang;
}
public float getDinhMuc() {
return DinhMuc;
}
public void setDinhMuc(float dinhMuc) {
DinhMuc = dinhMuc;
}

public KhachHangVietNam() {
super();
}

public KhachHangVietNam(String ma_so, String ten_khach, String dia_chi,float so_kw,float don_gia, float thanh_tien,
String loai_khach, float dinh_muc) {
super(ma_so,ten_khach,dia_chi,so_kw,don_gia,thanh_tien);
this.setLoaiKhachHang(loai_khach);
this.setDinhMuc(dinh_muc);
}

public void nhapThongTin() {
super.nhapThongTin();
Scanner sc = new Scanner(System.in);
System.out.print("Nhập loại khách hàng: ");
String loai = sc.nextLine();
this.setLoaiKhachHang(loai);

System.out.print("Nhập định mức: ");
float dinhmuc = sc.nextFloat();
this.setDinhMuc(dinhmuc);
}

public float tinhTien() {
float vuoc_dinh_muc = this.getSoLuongKW() - this.getDinhMuc();
if(this.getSoLuongKW() <= this.getDinhMuc()) this.setThanhTien(this.getSoLuongKW()*this.getDonGia());
else {
this.setThanhTien(this.getSoLuongKW()*this.getDonGia()*this.getDinhMuc() + (vuoc_dinh_muc*this.getDonGia()*(float) 2.5));
}

return this.getThanhTien();
}

public void xuatThongTin() {
super.xuatThongTin();
System.out.println("Loại khách hàng: "+this.getLoaiKhachHang()+"\nĐịnh Mức: "+this.getDinhMuc()+"\nGía= "+this.tinhTien());
}


}
Class Khách Nước Ngoài
import java.util.*;
public class KhachNuocNgoai extends KhachHang{

private String QuocTich;

public String getQuocTich() {
return QuocTich;
}

public void setQuocTich(String quocTich) {
QuocTich = quocTich;
}

public KhachNuocNgoai() {
super();
}

public KhachNuocNgoai(String ma_so, String ten_khach, String dia_chi,float so_kw,float don_gia, float thanh_tien, String quoc_tich) {
super(ma_so,ten_khach,dia_chi,so_kw,don_gia,thanh_tien);
this.setQuocTich(quoc_tich);
}

public void nhapThongTin() {
super.nhapThongTin();
Scanner sc = new Scanner(System.in);
System.out.print("Nhập quốc tịch: ");
String quoctich = sc.nextLine();
this.setQuocTich(quoctich);
}

public float tinhTien() {
this.setThanhTien(this.getSoLuongKW()*this.getDonGia());
return this.getThanhTien();
}

public void xuatThongTin() {
super.xuatThongTin();
System.out.println("Quốc Tịch: "+this.getQuocTich()+"\nGía: "+this.tinhTien());

}
}
Câu 3:
Class Danh Sách Khách Hàng

public class ListKhachHang {

private int count = 0, count_vn = 0, count_nn = 0;
KhachHangVietNam[] vn = new KhachHangVietNam[100];
KhachNuocNgoai[] nn = new KhachNuocNgoai[100];

public void kiemTra(int luachon) {
if(count > 100) System.out.println("Không thể thêm data...");
else {
if(luachon == 1) {
vn[count_vn] = new KhachHangVietNam();
KhachHangVietNam vnn = new KhachHangVietNam();
vnn.nhapThongTin();
count_vn++;
count++;
}
else if(luachon == 4) {
nn[count_nn] = new KhachNuocNgoai();
KhachNuocNgoai nuocn = new KhachNuocNgoai();
nuocn.nhapThongTin();
count++;
count_nn++;
}
}
}

public void outPutDisPlay() {
System.out.println("khách Việt Nam");
for(int i=0; i<count_vn; i++)
vn[i].xuatThongTin();

System.out.println("Khách Nước Ngoài");
for(int i=0; i<count_nn; i++)
nn[i].xuatThongTin();

}

public void tienCaoNhat() {
float tien = 0, tien1 = 0, result = 0;
for(int i=0; i<count_vn; i++)
if(vn[i].tinhTien() > 0) tien = vn[i].tinhTien();

for(int i=0; i<count_nn; i++)
if(nn[i].tinhTien() > 0) tien1 = nn[i].tinhTien();

result = (tien > tien1) ? tien : tien1;

if(tien > tien1) {
int i=0;
float a =0;
for(; i<count_vn; i++)
if(vn[i].tinhTien() > 0) tien = vn[i].tinhTien();

vn[i].xuatThongTin();
}
else {
int i=0;
float a =0;
for(; i<count_nn; i++)
if(nn[i].tinhTien() > 0) tien = nn[i].tinhTien();

nn[i].xuatThongTin();
}

}

public void so_kwThapNhat() {
float tien = 0, tien1 = 0, result = 0;
for(int i=0; i<count_vn; i++)
if(vn[i].getSoLuongKW() < 0) tien = vn[i].tinhTien();

for(int i=0; i<count_nn; i++)
if(nn[i].getSoLuongKW() < 0) tien1 = nn[i].tinhTien();

result = (tien > tien1) ? tien : tien1;

if(tien < tien1) {
int i=0;
float a =0;
for(; i<count_vn; i++)
if(vn[i].getSoLuongKW() < 0) tien = vn[i].tinhTien();

vn[i].xuatThongTin();
}
else {
int i=0;
float a =0;
for(; i<count_nn; i++)
if(nn[i].getSoLuongKW() < 0) tien = nn[i].tinhTien();

nn[i].xuatThongTin();
}
}
}
Câu 4:
Class Test Khách Hàng
import java.util.Scanner;

public class TestKhachHang {

public static void main(String[] args) {
ListKhachHang khach = new ListKhachHang();

Scanner sc = new Scanner(System.in);
int luachon;

do {

System.out.println("============== MENU ============");
System.out.println("| 0. Thoát |");
System.out.println("| 1. Nhập Khách Việt Nam |");
System.out.println("| 2. Nhập Khách Nước Ngoài |");
System.out.println("| 3. Hiển Thị Danh Sách Khách Hàng|");
System.out.println("| 4. Khách có gái tiền cao nhất |");
System.out.println("| 5. Khách có giá KW thấp nhất |");
System.out.println("==================================");

System.out.print("Bạn Muốn Chọn: "); luachon =sc.nextInt();

switch(luachon) {
case 1: khach.kiemTra(luachon); break;
case 2: khach.kiemTra(luachon); break;
case 3: khach.outPutDisPlay(); break;
case 4: khach.tienCaoNhat(); break;
case 5: khach.so_kwThapNhat(); break;
}

}while(luachon != 0);
}
}
Có thể xem thêm tại: Java Programming

Bài 1 - Tuần 4

/ No Comments
Kham Khảo


/*
*Code by Vy Nguyễn
*/

package Pointttt;
import java.util.Scanner;

public class Point {

private String NamePoint;
private float Tung, Hoanh;
public String getNamePoint() {
return NamePoint;
}
public void setNamePoint(String namePoint) {
NamePoint = namePoint;
}
public float getTung() {
return Tung;
}
public void setTung(float tung) {
Tung = tung;
}
public float getHoanh() {
return Hoanh;
}
public void setHoanh(float hoanh) {
Hoanh = hoanh;
}

public Point() {
super();
this.setNamePoint("A");
this.setTung(0);
this.setHoanh(0);
}

public Point(float tung, float hoanh) {
super();
this.setTung(tung);
this.setHoanh(hoanh);
}

public Point(String name, float tung, float hoanh) {
super();
this.setNamePoint(name);
this.setTung(tung);
this.setHoanh(hoanh);
}

public void inPutKey() {
Scanner sc = new Scanner(System.in);
System.out.print("Nhập Tên Điểm: ");
String name = sc.nextLine(); this.setNamePoint(name);

System.out.print("Nhập Tung Độ: ");
float tung = sc.nextFloat(); this.setTung(tung);

System.out.print("Nhập Hoành Độ: ");
float hoanh = sc.nextFloat(); this.setHoanh(hoanh);

}

public float khoangCach(Point a, Point b) {
return (float) Math.sqrt( (Math.pow( a.getHoanh() - b.getHoanh() , 2)) + (Math.pow(a.getTung() - b.getTung(), 2)) );
}

public void outPutDisPlay() {
System.out.println("\nName: "+this.getNamePoint()+"\t ("+this.getHoanh()+" , " + this.getTung()+")");
}

//======================== MAIN ===============================
public static void main(String[] args) {

// Point p1 = new Point();
// p1.outPutDisPlay();
//
// Point p2 = new Point(2.1f, 4.5f);
// p2.outPutDisPlay();
//
// Point p3 = new Point("D", 3.3f, 10.2f);
// p3.outPutDisPlay();

Point p4 = new Point();
p4.inPutKey();

Point p5 = new Point();
p5.inPutKey();

Point p6 = new Point();
System.out.println(p6.khoangCach(p4, p5));

}
}


Có thể xem thêm tại: Java Programming

Bài Tập Java Tuần 6 Tổng Hợp

/ No Comments


Bài Kham Khảo

a) Lớp Cha ( Tên chuyến xe (tuỳ người đặt, thích j đặt đó) ).
/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

import java.util.Scanner;
public class ChuyenXe {

// protected thì con có thể truy cập nếu không phải con sẽ không truy cập được
protected String Name, Code, SoXe;
protected double DoanhThu;

// Phương thức set, get dùng để nhận và lấy giá trị
public String getName() {
return Name;
}
protected void setName(String name) {
Name = name;
}
protected String getCode() {
return Code;
}
protected void setCode(String code) {
Code = code;
}
protected String getSoXe() {
return SoXe;
}
protected void setSoXe(String soXe) {
SoXe = soXe;
}
protected double getDoanhThu() {
return DoanhThu;
}
protected void setDoanhThu(double doanhThu) {
DoanhThu = doanhThu;
}

// Constructor khỏi tạo không tham số truyền vào
public ChuyenXe() {
super();
this.setName("");
this.setCode("");
this.setSoXe("");
this.setDoanhThu(0);
}

// Constructor khỏi tạo có tham số truyền vào
public ChuyenXe(String name, String code, String soxe, double doanhthu) {
super();
this.setName(name);
this.setCode(code);
this.setSoXe(soxe);
this.setDoanhThu(doanhthu);
}

// Phương thức nhập giá trị từ bàn phím
public void inPutDisPlay() {
Scanner sc = new Scanner(System.in);
String n, ms, sx; double dt;

System.out.print("Nhập Tên: ");
n = sc.nextLine(); this.setName(n);

System.out.print("Nhập Mã Số: ");
ms = sc.nextLine(); this.setCode(ms);

System.out.print("Nhập Số Xe: ");
sx = sc.nextLine(); this.setSoXe(sx);

System.out.print("Nhập Doanh Thu: ");
dt = sc.nextDouble(); this.setDoanhThu(dt);
}

// phương thức xuất giá trị ra màn hình
public String outPutDisPlay() {
return "\n=========== Xuất Thông Tin ==========="+"\nTên: " + this.getName() + "\nMã Số: " + this.getCode() + "\nSố Xe: " + this.getSoXe() + "\nDoanh Thu: " + this.getDoanhThu();
}
}



b) Lớp con (Tên ngoại div> thành)
/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

import java.util.Scanner;
public class NgoaiThanh extends ChuyenXe{

// Thuộc tính
private String NoiDen;
private int NgayDiDuoc;

// Phương thức nhận và lấy giá trị (get,set)
public String getNoiDen() {
return NoiDen;
}
public void setNoiDen(String noiDen) {
NoiDen = noiDen;
}
public int getNgayDiDuoc() {
return NgayDiDuoc;
}
public void setNgayDiDuoc(int ngayDiDuoc) {
NgayDiDuoc = ngayDiDuoc;
}

// Constructor khỏi tạo không tham số truyền vào
public NgoaiThanh() {
super();
}

// Constructor khỏi tạo có tham số truyền vào
public NgoaiThanh(String name, String code, String soxe, double doanhthu, String noiden, int ngay) {
super(name, code, soxe, doanhthu);
this.setName(noiden);
this.setNgayDiDuoc(ngay);
}

// Phương thức nhập giá trị từ bàn phím
public void inPutDisPlay() {
super.inPutDisPlay(); // do cha có sẳn nên xài ké vậy thôi
// viết lại làm gì cho dai dòng
// super.inPutDisPlay() nó có nghĩa là hàm đó từ cha
Scanner sc = new Scanner(System.in);
String noi; int ngay;
System.out.print("Nhập Nơi Đến: ");
noi = sc.nextLine(); this.setNoiDen(noi);

System.out.print("Nhập Số Ngày: ");
ngay = sc.nextInt(); this.setNgayDiDuoc(ngay);
}

// phương thức xuất giá trị ra màn hình
public String outPutDisPlay() {
return super.outPutDisPlay() + "\nNơi Đến: " + this.getNoiDen() + "\nSố Ngày: " + this.getNgayDiDuoc(); // nối chuỗi thôi
}
}




c) Lớp con (Tên nội thành tương tự ngoại thành)

/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

import java.util.Scanner;
public class NoiThanh extends ChuyenXe{

private float QuangDuong;
private int SoTuyen;

public float getQuangDuong() {
return QuangDuong;
}

public void setQuangDuong(float quangDuong) {
QuangDuong = quangDuong;
}

public int getSoTuyen() {
return SoTuyen;
}

public void setSoTuyen(int soTuyen) {
SoTuyen = soTuyen;
}

public NoiThanh() {
super();
}

public NoiThanh(String name, String code, String soxe, double doanhthu, float duong, int sotuyen) {
super(name,code,soxe,doanhthu);
this.setQuangDuong(duong);
this.setSoTuyen(sotuyen);
}

public void inPutDisPlay() {
super.inPutDisPlay();
Scanner sc = new Scanner(System.in);
float duong; int tuyen;

System.out.print("Nhập Quãng Đường: ");
duong = sc.nextFloat(); this.setQuangDuong(duong);

System.out.print("Nhập Số Tuyến: ");
tuyen = sc.nextInt(); this.setSoTuyen(tuyen);
}

public String outPutDisPlay() {
return super.outPutDisPlay() + "\nQuãng Đường: " + this.getQuangDuong() + "\nSố Tuyến: " + this.getSoTuyen();
}
}


d) Lớp danh sách xe 

/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/


public class ListChuyenXe {

private double sum1 = 0, sum2 = 0;
private int coutList = 0;

ChuyenXe[] CX = new ChuyenXe[100]; // tạo mảng xủa chuyến xe

public void List() { // hàm dùng khỏi tạo giá trị cho mảng
for(int i=0; i<100; i++)
CX[i]= new ChuyenXe() {
};
}


public void kiemTra(int chon) { // hàm kiểm tra xem người dùng chọn gì
if(coutList > 100)
System.out.println("Không Thể Thêm Dữ Liệu!!!");

else {
if(chon == 1) {
CX[coutList] = new NoiThanh();
NoiThanh noithanh = new NoiThanh();
noithanh.inPutDisPlay();
CX[coutList] = noithanh;
sum1 += noithanh.getDoanhThu();
}

else {
CX[coutList] = new NgoaiThanh();
NgoaiThanh ngoaithanh = new NgoaiThanh();
ngoaithanh.inPutDisPlay();
CX[coutList] = ngoaithanh;
sum2 += ngoaithanh.getDoanhThu();
}
coutList++;
}
}

// xuất thông tin
public void OUTPUTDISPLAY() {
for(int i=0; i< coutList; i++) {
System.out.println("\n=================================================\n");
System.out.println(CX[i].outPutDisPlay());

System.out.println("\n============== Doanh Thu ======================\n");
System.out.println("Chuyến Xe Nội Thành: "+ sum1+"\nChuyến Xe Ngoại Thành: "+sum2);
}
}
}


e) Hàm test (hay nói cách khác hàm chạy chương trình )

/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

import java.util.Scanner;

import javax.print.DocFlavor.INPUT_STREAM;
public class TestChuyenXe {

public static void main(String[] args) {
int a;
Scanner sc = new Scanner(System.in);
ListChuyenXe chuyenxe = new ListChuyenXe();

do {
System.out.println("================================ MENU ============================\n");
System.out.println("|| 0. Thoát ||");
System.out.println("|| 1. Xe Nội Thành ||");
System.out.println("|| 2. Xe Ngoại Thành ||");
System.out.println("|| 3. Xuất Danh Sách ||");
System.out.println("=====================================================================");

System.out.print("Bạn Muốn Chọn: "); a = sc.nextInt();

switch(a) {
case 1: chuyenxe.kiemTra(1); break;
case 2: chuyenxe.kiemTra(2); break;
case 3: chuyenxe.OUTPUTDISPLAY(); break;
}
}while(a != 0);

}
}


Có thể xem thêm tại: Java Programming

Giải Đề Thi 2017

/ No Comments
Phần 1: ( 5đ )


Phần 2: ( 5đ ) 

Câu 1: Xây dựng phương thức nhập vào một mảng các số nguyên.
Câu 2: Xây dựng phương thức tính tổng các phần tử chia hết cho 5.
Câu 3: Xây dựng phương thức đếm các số hoàn hảo.
Câu 4: Xây dựng phương thức main, trong đó khai báo một mảng các số nguyên có n phần tử. Với n được nhập từ bàn phím và n > 0. Gọi thực thi các phương thức trên.


Bài Kham Khảo
Phần 1
Câu 1 + Câu 2
Class Nhà Trọ
// Code by Tuấn 
//Edit code by Vy Nguyễn

public abstract class NhaTro {

private String MaSo, TenNhaTro;
private double DonGia;
public String getMaSo() {
return MaSo;
}
public void setMaSo(String maSo) {
MaSo = maSo;
}
public String getTenNhaTro() {
return TenNhaTro;
}
public void setTenNhaTro(String tenNhaTro) {
TenNhaTro = tenNhaTro;
}
public double getDonGia() {
return DonGia;
}
public void setDonGia(double donGia) {
DonGia = donGia;
}

public NhaTro() {
super();
}

public NhaTro(String ma_so, String ten_nha_tro, double don_gia) {
super();
this.setMaSo(ma_so);
this.setTenNhaTro(ten_nha_tro);
this.setDonGia(don_gia);
}

public abstract double tinhTienPhong();
}


Class Phòng Ngày
// Code by Tuấn 
//Edit code by Vy Nguyễn
public class PhongNgay extends NhaTro{

private double TienDichVu;
private int LoaiPhong;
public double getTienDichVu() {
return TienDichVu;
}
public void setTienDichVu(double tienDichVu) {
TienDichVu = tienDichVu;
}
public int getLoaiPhong() {
return LoaiPhong;
}
public void setLoaiPhong(int loaiPhong) {
LoaiPhong = loaiPhong;
}

public PhongNgay() {
super();
}

public PhongNgay(String ms, String ten, double gia, double tien_dich_vu, int loai_phong) {
super(ms,ten,gia);
this.setTienDichVu(tien_dich_vu);
this.setLoaiPhong(loai_phong);
}

public double tinhTienPhong() {
if(this.getLoaiPhong() == 1) return (this.getDonGia() + this.getTienDichVu()) + ((this.getDonGia() + this.getTienDichVu())*0.4);
else return (this.getDonGia() + this.getTienDichVu());

}

}


Class Phòng Tháng
// Code by Tuấn 
//Edit code by Vy Nguyễn

public class PhongThang extends NhaTro{

private double TienDienNuoc;

public double getTienDienNuoc() {
return TienDienNuoc;
}

public void setTienDienNuoc(double tienDienNuoc) {
TienDienNuoc = tienDienNuoc;
}

public PhongThang() {
super();
}

public PhongThang(String ms, String ten, double don_gia, double tien_dien_nuoc) {
super(ms,ten,don_gia);
this.setTienDienNuoc(tien_dien_nuoc);
}

public double tinhTienPhong() {
return (double) this.getDonGia() + this.getTienDienNuoc();
}

}


Class Test Nhà Trọ
// Code by Tuấn 
//Edit code by Vy Nguyễn

import java.util.*;
public class TestNhaTro {

public static void main(String[] args) {
PhongNgay ngay = new PhongNgay("DTh111","Phi Long", 1800,8000 ,2);
System.out.println("Giá Tiền Phòng Thường: "+ngay.tinhTienPhong());

PhongNgay ngay1 = new PhongNgay("DTH113","Long Phi", 25000, 9800, 1);
System.out.println("Giá Tiền Phòng VIP: "+ngay1.tinhTienPhong());

PhongThang thang = new PhongThang("DTh112","Phi Phi Long", 18000, 175000);
System.out.println("Giá Tiền Thuê Tháng: "+thang.tinhTienPhong());

}

}


Phần 2
Câu 1 + 2+ 3 + 4
// Code by Tuấn
// Edit code by Vy Nguyễn
import java.util.*;
public class MangSoNguyenTo {
// Hàm Nhập Bình Thường để nhập số lượng phần tử
public int inPut(){
Scanner sc = new Scanner(System.in);
int n;
do{
n = sc.nextInt();
}while(n < 0);
return n;
}

//Hàm Nhập Mảng
public void inPut_Arr(int[] a) {
for(int i=0; i<a.length; i++) {
System.out.print("a["+(i+1)+"]= ");
a[i] = inPut();
}
}

// Hàm Tổng Phần Tử Chia Hết Cho 5
public void tongPhanTuChiaHetCho_5(int[] a) {
int total = 0;
for(int i=0; i<a.length; i++)
if(a[i] % 5 == 0) total+= a[i];

System.out.println("Tổng= "+total);
}

// Hàm Kiểm Tra Số Hoàn Hảo
public boolean hoanhao(int n) {
int s = 0;
for(int i=2; i<=n; i++)
if(n%i == 0) s= s+(n/i);
if(s == n) return true;
else return false;
}

//Hàm Đếm Số Hoàn Hảo
public int cout_So_Hoan_Hao(int[] a) {
int count = 0;
for(int i=0; i<a.length; i++)
if(hoanhao(a[i]) == true) count++;
return count;
}


// Hàm Main
public static void main(String[] args) {
// Tạo đối tượng
MangSoNguyenTo h = new MangSoNguyenTo();

System.out.print("Nhập số lượng phần tử: ");
int n = h.inPut();
int[] a = new int[n];

System.out.println("Nhập mảng");
h.inPut_Arr(a);
h.tongPhanTuChiaHetCho_5(a);
System.out.println("Số Lượng Các Số Hoàn Hảo: "+h.cout_So_Hoan_Hao(a));
}
}





Chú Thích


- Mấy bạn cứ làm theo phần tạo cái gì đó trong ổ
Z theo đề iu cầu, Ở đây tui chỉ cung cấp code thôi
nha!!!
Có thể xem thêm tại: Java Programming

Bài Tổng Hợp Project Hàng Hoá

/ No Comments

Bài Kham Khảo


a) Class Hàng Hóa
/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

package Bai4;
import java.util.*;

public abstract class HangHoa {

protected String Code, Name;
protected float GiaBan;

protected String getCode() {
return Code;
}
protected void setCode(String code) {
Code = code;
}
protected String getName() {
return Name;
}
protected void setName(String name) {
Name = name;
}
protected float getGiaBan() {
return GiaBan;
}
protected void setGiaBan(float giaBan) {
GiaBan = giaBan;
}

public HangHoa() {
super();
}

public HangHoa(String name, String code, float giaban) {
super();
this.setName(name);
this.setCode(code);
this.setGiaBan(giaban);
}

public abstract float Price();

public void inPutKeyBoard() {
Scanner sc = new Scanner(System.in);

System.out.print("Nhập Tên Sản Phẩm: ");
String name = sc.nextLine(); this.setName(name);
// Cách nhập khác nha: this.setName(sc.nextLine()); cũng giống như trên đều set giá trị

System.out.print("Nhập Mã Sản Phẩm: ");
String code = sc.nextLine(); this.setCode(code);

System.out.print("Nhập Giá Bán: ");
float gia = sc.nextFloat(); this.setGiaBan(gia);
}

public String outPutDisPlay() {
return "\n======== Xuất =========" + "\nTên Sản Phẩm: " + this.getName() + "\nMã Sản Phẩm: " + this.getCode() + "\nGía Bán: " + this.getGiaBan() + " VND";
}
}



b) Class Hàng Thường
/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

package Bai4;
import java.util.*;

public class HangThuong extends HangHoa{

private float VAT;

public float getVAT() {
return VAT;
}

public void setVAT(float vAT) {
VAT = vAT;
}

public HangThuong() {
super();
}

public HangThuong(String name, String code, float gia, float vat) {
super(name,code,gia);
this.setVAT(vat);
}


public void inPutKeyBoard() {
super.inPutKeyBoard();
Scanner sc = new Scanner(System.in);
System.out.print("Nhập VAT Hàng Thường: ");
float vat = sc.nextFloat(); this.setVAT(vat);
}

public float Price() {
return this.getGiaBan() + this.getGiaBan() * this.getVAT();
}

public void outPutDisPlays() {
System.out.println(super.outPutDisPlay() + "\nGía VAT Hàng Thường: " + this.getVAT() + "\nGiá Sản Phẩm: " + this.Price() + " VND");

}
}



c) Class Hàng Khuyến Mãi
/*
*Code by: Hoàng Minh Tuấn
*Edit Code: Vy Nguyễn
*/

package Bai4;
import java.util.*;

public class HangKhuyenMai extends HangHoa{

private float SoTienGiam;

public float getSoTienGiam() {
return SoTienGiam;
}

public void setSoTienGiam(float soTienGiam) {
SoTienGiam = soTienGiam;
}

public HangKhuyenMai() {
super();
}

public HangKhuyenMai(String name, String code, float gia, float tiengiam) {
super(name,code,gia);
this.setSoTienGiam(tiengiam);
}

public void inPut() {
super.inPutKeyBoard();
Scanner sc = new Scanner(System.in);
System.out.print("Số Tiền Được Giảm: ");
float giam = sc.nextFloat(); this.setSoTienGiam(giam);
}

public float Price() {
return this.GiaBan - this.getSoTienGiam();
}

public void outPutDS() {
System.out.println(super.outPutDisPlay() + "\nSố Tiền Được Giảm: " + this.getSoTienGiam() + "\nGiá Bán Sản Phẩm: " + this.Price() + " VND");
}
}



d) Class Danh Sách Hàng
/*
*Code By Vy Nguyễn
*/
package Bai4;

public class ListHangHoa2 {

private int coutList = 0, coutthuong = 0, coutkm = 0;

HangHoa[] hanghoa1 = new HangHoa[100];
HangThuong[] hangthuong = new HangThuong[100];
HangKhuyenMai[] khuyenmai = new HangKhuyenMai[100];

public void list() {
for(int i=0; i<100; i++) {

hanghoa1[i] = new HangHoa() {

@Override
public float Price() {
// TODO Auto-generated method stub
return 0;
}
};
// hangthuong[i] = new HangThuong();
// khuyenmai[i] = new HangKhuyenMai();

}
}

public void kiemTra(int key) {
if(coutList > 100) System.out.println("Không thể nhập dữ liệu");
else {

if(key == 1) {
hanghoa1[coutList] = new HangThuong();
hangthuong[coutthuong] = new HangThuong();
hangthuong[coutthuong].inPutKeyBoard();
hanghoa1[coutList] = hangthuong[coutthuong];
coutthuong++;
}

else if(key == 2) {
hanghoa1[coutList] = new HangKhuyenMai();
khuyenmai[coutkm] = new HangKhuyenMai();
khuyenmai[coutkm].inPut();
hanghoa1[coutList] = khuyenmai[coutkm];
coutkm++;
}

coutList++;
}
}

public void XuatDisPlay(int key) {
if(key == 3) {
for(int i=0; i<coutthuong; i++)
hangthuong[i].outPutDisPlays();
}
else if(key == 4) {
for(int i=0; i<coutkm; i++)
khuyenmai[i].outPutDS();
}
}
}







e) Main Test
/*
*Code By Vy Nguyễn
*/
package Bai4;
import java.util.Scanner;
public class TestHangHoa {

public static void main(String[] args) {
ListHangHoa2 h1 = new ListHangHoa2();
Scanner sc = new Scanner(System.in);
int luachon;

do {

System.out.println(" =============================== MENU ============================\n");
System.out.println("|| 0. Thoát ||");
System.out.println("|| 1. Hàng Thường ||");
System.out.println("|| 2. Hàng Khuyến Mãi ||");
System.out.println("|| 3. Xuất Danh Sách Hàng Thường ||");
System.out.println("|| 4. Xuất Danh Sách Hàng Khuyến Mãi ||");
System.out.println(" ==================================================================");

System.out.print("Bạn Chọn: "); luachon = sc.nextInt();

switch(luachon) {

case 1: h1.kiemTra(luachon); break;

case 2: h1.kiemTra(luachon); break;

case 3: h1.XuatDisPlay(luachon); break;

case 4: h1.XuatDisPlay(luachon); break;

}

}while(luachon != 0);
}
}


f) Giải Thích Code
* Dùng Protected vì đảm bảo tính bảo mật chỉ con mới có thể truye cập được
* Code này chưa tối giản được nó còn sai tui chưa biết sửa để nủa ông tuấn code lại
tui sửa tiếp
* Mấy cái còn lại thì quen thuộc với mọi người rồi
(mà nhớ trong constructor của con thì nhớ để super() là được ^_^)
* Vì sao lại phải dùng tùm lum mảng vậy, vì mình cần xuất ra thông tin và
giá bán sản phẩm mà nhiều sản phẩm thì dùng mảng vậy thôi
Có thể xem thêm tại: Java Programming