1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lập trình hướng Đối tượng Đề tài quản lý phiếu Điểm của sinh viên trong trường Đại học

35 1 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Quản lý phiếu điểm của sinh viên trong trường đại học
Tác giả Nguyễn Thế Vũ, Hoàng Minh Duy, Nguyễn Đức Phong
Người hướng dẫn Nguyễn Đức Tuấn
Trường học Trường Đại Học Mở Hà Nội
Chuyên ngành Công Nghệ Thông Tin
Thể loại Bài tập lớn
Năm xuất bản 2024
Thành phố Hà Nội
Định dạng
Số trang 35
Dung lượng 2,02 MB

Cấu trúc

  • I. PHÁT BIỂU BÀI TOÁN (5)
    • 1.1 Phát biểu vấn đề (5)
    • 1.2. Mục tiêu (5)
  • II. XÁC ĐỊNH SƠ ĐỒ BÀI TOÁN (6)
    • 2.1 Các lớp được cài đặt (6)
    • 2.2 Quan hệ giữa các lớp (6)
    • 2.3 Sơ đồ quan hệ (7)
  • III. MÔ TẢ THUẬT TOÁN – THAO TÁC (7)
  • IV. CODE (8)
  • V. KIỂM THỬ - LẬP BỘ TEST (27)
  • TÀI LIỆU THAM KHẢO (35)

Nội dung

LỜI NÓI ĐẦUTrong thời đại của công nghệ thông tin phát triển mạnh mẽ nhưhiện nay, việc quản lý thông tin và tài nguyên trong các cơ sở giáodục, như thư viện của trường đại học, đặt ra nh

PHÁT BIỂU BÀI TOÁN

Phát biểu vấn đề

Phân tích đề bài “Quản lý phiếu điểm sinh viên trong trường đại học”

Quản lý phiếu điểm sinh viên là một công việc quan trọng, đòi hỏi ghi nhận và cập nhật thông tin hàng ngày như mã phiếu điểm, ngày lập, và nội dung phiếu Đồng thời, cần quản lý thông tin cán bộ lập phiếu với mã cán bộ, họ tên, năm sinh và giới tính Ngoài ra, thông tin sinh viên như mã sinh viên, họ tên, giới tính và địa chỉ cũng không thể thiếu Việc phát triển một chương trình hoặc phần mềm hỗ trợ quản lý sẽ nâng cao hiệu quả hoạt động của trường đại học, đặc biệt trong việc quản lý phiếu điểm.

Mục tiêu

- Hỗ trợ việc quản lý phiếu điểm chính xác, nhanh chóng và hiệu quả.

 Tiết kiệm thời gian, nhân lực.

 Dữ liệu luôn mang tính nhất quán, được cập nhật thường xuyên.

 Hỗ trợ tra cứu và lập báo cáo nhanh chóng, chính xác.

Các yêu cầu chi tiết

 Có Menu gọi các chức năng của bài toán

 Đọc ghi các file dữ liệu

 Đọc ghi theo thống kê

Cụ thể ở thao tác quản lý hóa đơn bán hàng:

XÁC ĐỊNH SƠ ĐỒ BÀI TOÁN

Các lớp được cài đặt

- Thuộc tính: hoTen, diaChi, gioiTinh

- Phương thức: khởi tạo, get/set, nhapPerson, toString

- Phương thức: khởi tạo, get/set, nhapPerson, toString

- Phương thức: khởi tạo, get/set, nhapPerson, toString

- Thuộc tính: ngayL, thangL, namL, maPhieu, maMon, diemcc, diemgk, diemck, CanBo cvht, SinhVien sv

- Phương thức: khởi tạo, get/set, nhapPhieuDiem, hienPhieuDiem, toString

- Phương thức: nhapDS, xuatDS, luuFile, docFile, themPhieuDiemMoi, xoaPhieu, timKiemPhieuTheoMa, suaPhieu, inPhieuDiemCKLonHon8, xuatThongTinSinhVienTrongPhieu, xuatThongTinCanBoTrongPhieu

Quan hệ giữa các lớp

- CanBo và SinhVien kế thừa từ Person

- Implements các lớp Person, PhieuDiem, QuanLiDanhSach từ lớp Serializable

MÔ TẢ THUẬT TOÁN – THAO TÁC

Các thap tác cần xử lí:

- Nhập dữ liệu từ bàn phím và ghi thông tin vào file

- Đọc file và hiện dữ liệu phiếu điểm

- In phiếu điểm có điểm cuối kì lớn hơn 8

- Xuất thông tin chi tiết sinh viên

- Xuất thông tin chi tiết cán bộ lập phiếu điể

CODE

The Person class, part of the QuanLiPhieuDiem package, implements the Serializable interface and defines three protected attributes: hoTen (name), diaChi (address), and gioiTinh (gender) It includes a constructor that initializes these attributes with the provided values.

} public Person(){} public String getHoTen() { return hoTen;

} public void setHoTen(String hoTen) { this.hoTen = hoTen;

} public String getDiaChi() { return diaChi;

} public void setDiaChi(String diaChi) { this.diaChi = diaChi;

} public String getGioiTinh() { return gioiTinh;

} public void setGioiTinh(String gioiTinh) { this.gioiTinh = gioiTinh;

Scanner scanner = new Scanner(System.in);

System.out.print("Ho ten: "); hoTen=scanner.nextLine();

System.out.print("Dia chi: "); diaChi=scanner.nextLine();

System.out.print("Gioi tinh: "); gioiTinh=scanner.nextLine();

@Override public String toString() { return "Person [hoTen=" + hoTen + ", diaChi=" + diaChi + ", gioiTinh=" + gioiTinh + "]";

The LỚP SINHVIEN package, part of the QuanLiPhieuDiem system, defines a SinhVien class that extends the Person class It includes attributes such as maSV, which represents the student ID The constructor initializes the student's name, address, gender, and student ID by calling the superclass constructor and setting the maSV attribute.

} public SinhVien() {} public String getMaSV() { return maSV;

} public void setMaSV(String maSV) { this.maSV = maSV;

// TODO Auto-generated method stub

Scanner scanner = new Scanner(System.in);

System.out.print("Ma sinh vien: "); maSV= scanner.nextLine(); super.nhapPerson();

@Override public String toString() { return "maSV: " + maSV ;

The CanBo class, part of the QuanLiPhieuDiem package, extends the Person class and implements Serializable It includes a private field for the teacher's ID (maGV) and a constructor that initializes the teacher's name, address, gender, and ID by calling the superclass constructor.

} public CanBo() {} public String getMaGV() { return maGV;

} public void setMaGV(String maGV) { this.maGV = maGV;

Scanner scanner = new Scanner(System.in);

System.out.print("Ma giao vien: "); maGV=scanner.nextLine(); super.nhapPerson();

@Override public String toString() { return "maGV: " + maGV;

The PhieuDiem package, part of the QuanLiPhieuDiem system, includes a Java class named PhieuDiem that implements the Serializable interface This class contains attributes for recording date components (day, month, year), as well as identifiers for the score sheet and subject, along with three double variables to store continuous assessment, midterm, and final exam scores.

The code snippet initializes a Scanner object for user input and defines a constructor for the PhieuDiem class This constructor takes parameters for the day, month, and year of the record, along with the record ID, subject code, continuous assessment score, midterm score, final exam score, the supervising staff member, and the student These parameters are then assigned to the class attributes, encapsulating the essential details of a student's academic record.

} public PhieuDiem(){} public int getNgayL() { return ngayL;

} public void setNgayL(int ngayL) { this.ngayL = ngayL;

} public int getThangL() { return thangL;

} public void setThangL(int thangL) { this.thangL = thangL;

} public int getNamL() { return namL;

} public void setNamL(int namL) { this.namL = namL;

} public String getMaPhieu() { return maPhieu;

} public void setMaPhieu(String maPhieu) { this.maPhieu = maPhieu;

} public String getMaMon() { return maMon;

} public void setMaMon(String maMon) { this.maMon = maMon;

} public double getDiemcc() { return diemcc;

} public void setDiemcc(double diemcc) { this.diemcc = diemcc;

} public double getDiemgk() { return diemgk;

} public void setDiemgk(double diemgk) { this.diemgk = diemgk;

} public double getDiemck() { return diemck;

} public void setDiemck(double diemck) { this.diemck = diemck;

} public CanBo getCvht() { return cvht;

} public void setCvht(CanBo cvht) { this.cvht = cvht;

} public SinhVien getSv() { return sv;

} public void setSv(SinhVien sv) { this.sv = sv;

System.out.println("============Nhap thong tin phieu============");

To begin, the user is prompted to enter a ticket code using `System.out.print("Nhap ma phieu: ");` Next, the program requests the user to input the day of creation, ensuring it is between 1 and 31 through a do-while loop Subsequently, the user is asked to enter the month, which must be between 1 and 12, also validated with a do-while loop Finally, the program requires the user to input the year, with the condition that it must be greater than or equal to 2024, again using a do-while loop for validation After collecting all inputs, the scanner moves to the next line to prepare for any further data entry.

To input course details, start by prompting the user for the course name using `System.out.print("Ma mon hoc: ");` followed by reading the input with `maMon = scanner.nextLine();` Next, gather the continuous assessment score by repeatedly asking for input until a valid score between 1 and 10 is entered: `do{System.out.print("Diem chuyen can: "); diemcc = scanner.nextInt();}while(diemcc10);` Similarly, request the mid-term score and ensure it falls within the acceptable range using a loop: `do{System.out.print("Diem giua ki: "); diemgk = scanner.nextInt();}while(diemgk10);` Lastly, obtain the final exam score with the same validation process: `do{System.out.print("Diem cuoi ki: "); diemck = scanner.nextInt();}while(diemck10);` After collecting all scores, clear the scanner buffer with `scanner.nextLine();`.

System.out.println("= bo"); cvht.nhapPerson();

System.out.println("==Sinh vien"); sv.nhapPerson();

} public void setScanner(Scanner scanner) { this.scanner = scanner;

@Override public String toString() { return "\n============Thong tin phieu diem============\n" + "Ma phieu " + maPhieu +

"\nNgay lap: " + ngayL + "/" + thangL + "/" + namL

The `QuanLiDanhSach` class, part of the `QuanLiPhieuDiem` package, is designed for managing a list of `PhieuDiem` objects It imports essential Java libraries for file handling and serialization, including `BufferedReader`, `BufferedWriter`, and `ObjectInputStream` The class maintains an `ArrayList` to store instances of `PhieuDiem`, and it includes a method named `nhapDS` for inputting data into this list This implementation ensures efficient data management and supports serialization for saving and loading the list of student records.

Scanner sc = new Scanner(System.in);

System.out.print("Nhap so luong phieu: "); int soLuong = sc.nextInt(); listPhieu = new ArrayList(soLuong); sc.nextLine(); // Đọc ký tự newline for (int i = 0; i < soLuong; i++) {

The code snippet prompts the user to enter information for a specific score sheet, indicated by the index (i + 1) A new score sheet object, PhieuDiem, is created, and a boolean variable, trungMaPhieu, is initialized to track duplicate entries The program enters a loop where it allows the user to input the score sheet details It checks for duplicate score sheet IDs by comparing the newly entered ID with existing ones in the list If a match is found, trungMaPhieu is set to true, indicating a duplicate entry.

System.out.println("Ma phieu da ton tai Moi nhap lai."); break;

} while (trungMaPhieu); listPhieu.add(pd);

} public void xuatDS() { for (int i = 0; i < listPhieu.size(); i++) {

System.out.print("Thong tin phieu so " + (i + 1)); listPhieu.get(i).hienPhieuDiem();

} public void luuFile() throws IOException {

File f = new File("DSHD.dat");

ObjectOutputStream objout = new ObjectOutputStream(fout);

// Loại bỏ đối tượng Scanner trước khi ghi dữ liệu for (PhieuDiem phieu : listPhieu) { phieu.setScanner(null);

} objout.writeObject(listPhieu); objout.close(); fout.close();

} public void docFile() throws IOException, ClassNotFoundException { File f = new File("DSHD.dat");

ObjectInputStream objin = new ObjectInputStream(fin); listPhieu = (ArrayList) objin.readObject();

// Đảm bảo không còn đối tượng Scanner trong danh sách for (PhieuDiem phieu : listPhieu) { phieu.setScanner(null);

Scanner scanner = new Scanner(System.in);

System.out.println("Nhap thong tin phieu diem moi");

// Tạo một đối tượng PhieuDiem mới

// Nhập thông tin cho bản ghi điểm mới newPhieuDiem.nhapPhieuDiem();

Check if the new score record already exists in the boolean list trungMaPhieu Initialize trungMaPhieu to false and iterate through the list of PhieuDiem If the MaPhieu of newPhieuDiem matches any MaPhieu in the list, set trungMaPhieu to true.

System.out.println("Ma phieu da ton tai vui long nhap lai"); newPhieuDiem.nhapPhieuDiem(); // Yêu cầu người dùng nhập lại thông tin break;

// Thêm bản ghi điểm mới vào danh sách listPhieu.add(newPhieuDiem);

// Hiển thị danh sách đã cập nhật cùng với bản ghi mới được thêm System.out.println("Danh sach phieu sau khi them"); xuatDS();

Scanner scanner = new Scanner(System.in);

System.out.print("Nhap ma phieu can xoa: ");

String maPhieuCanXoa = scanner.nextLine(); boolean daTimThay = false; for (int i = 0; i < listPhieu.size(); i++) { if (listPhieu.get(i).getMaPhieu().equals(maPhieuCanXoa)) { listPhieu.remove(i); daTimThay = true;

System.out.println("Phieu diem co ma " + maPhieuCanXoa + " da duoc xoa."); break;

System.out.println("Khong tim thay " + maPhieuCanXoa + " de xoa.");

// In lại danh sách sau khi xóa

System.out.println("Danh sach phieu sau khi duoc xoa:"); xuatDS();

Scanner scanner = new Scanner(System.in);

System.out.println("Nhap ma phieu can tim kiem: ");

String maPhieuCanTim = scanner.nextLine(); boolean timThay = false; for (PhieuDiem phieu : listPhieu) { if (phieu.getMaPhieu().equals(maPhieuCanTim)) {

System.out.println("Thong tin phieu diem can tim:"); phieu.hienPhieuDiem(); timThay = true; break;

System.out.println("Khong tim thay phieu voi ma " + maPhieuCanTim);

Scanner scanner = new Scanner(System.in);

System.out.print("Nhap ma phieu can sua: ");

String maPhieuCanSua = scanner.nextLine(); boolean timThay = false; for (PhieuDiem phieu : listPhieu) { if (phieu.getMaPhieu().equals(maPhieuCanSua)) {

Hệ thống sẽ yêu cầu nhập thông tin mới cho phiếu điểm Sau khi người dùng nhập dữ liệu, thông tin phiếu điểm sẽ được cập nhật thành công Thông báo sẽ hiển thị rằng thông tin cho phiếu điểm có mã đã được cập nhật.

System.out.println("Khong tim thay phieu voi ma " + maPhieuCanSua);

} public void inPhieuDiemCKLonHon8() { boolean coPhieuDiemLonHon8 = false;

System.out.println("Cac phieu diem co diem cuoi ki lon hon 8:"); for (PhieuDiem phieu : listPhieu) { if (phieu.getDiemck() > 8) { phieu.hienPhieuDiem(); coPhieuDiemLonHon8 = true;

System.out.println("Khong co phieu diem nao co diem cuoi ki lon hon 8.");

Scanner scanner = new Scanner(System.in);

System.out.print("Nhap ma phieu: ");

String maPhieu = scanner.nextLine(); boolean timThay = false; for (PhieuDiem phieu : listPhieu) { if (phieu.getMaPhieu().equals(maPhieu)) {

SinhVien sinhVien = phieu.getSv(); // Lấy đối tượng SinhVien từ đối tượng PhieuDiem if (sinhVien != null) {

System.out.println("Thong tin sinh vien trong ma phieu " + maPhieu + ":");

Hệ thống in ra mã sinh viên, họ và tên, địa chỉ, và giới tính của sinh viên Các thông tin khác của sinh viên sẽ được xuất ra khi tìm thấy.

System.out.println("Phieu co ma " + maPhieu + " khong co ma thong tin sinh vien."); timThay = true; break;

System.out.println("Khong tim thay phieu co ma " + maPhieu); }

Scanner scanner = new Scanner(System.in);

System.out.print("Nhap ma phieu: ");

String maPhieu = scanner.nextLine(); boolean timThay = false; for (PhieuDiem phieu : listPhieu) { if (phieu.getMaPhieu().equals(maPhieu)) {

CanBo canBo = phieu.getCvht(); // Lấy đối tượng CanBo từ đối tượng PhieuDiem if (canBo != null) {

System.out.println("Thong tin can bo trong ma phieu " + maPhieu + ":");

System.out.println("Ma sinh vien: " + canBo.getMaGV()); System.out.println("Ho va ten: " + canBo.getHoTen()); System.out.println("Dia chi: " + canBo.getDiaChi());

System.out.println("Gioi tinh: " + canBo.getGioiTinh()); // Xuất các thông tin khác của can bo timThay = true; break;

System.out.println("Phieu co ma " + maPhieu + " khong co ma thong tin can bo."); timThay = true; break;

System.out.println("Khong tim thay phieu co ma " + maPhieu); }

System.out.println("\ n=================MENU=================="); System.out.println("1 Nhap thong tin phieu diem"); System.out.println("2 Xuat thong tin phieu diem"); System.out.println("3 Ghi File");

System.out.println("4 Doc File");

System.out.println("5 Them phieu diem");

System.out.println("6 Xoa phieu");

System.out.println("7 Tim kiem phieu");

System.out.println("8 Sua phieu");

Đoạn mã trên thực hiện các chức năng như sau: Đầu tiên, in ra phiếu có điểm cuối kỳ lớn hơn 8, tiếp theo là xuất thông tin sinh viên, sau đó là xuất thông tin cán bộ, và cuối cùng là lựa chọn thoát khỏi chương trình.

 Main package QuanLiPhieuDiem; import java.io.IOException; import java.util.Scanner; import java.io.Serializable; public class Main { public static void main(String[] args) throws IOException, ClassNotFoundException {

Scanner sc = new Scanner(System.in);

QuanLiDanhSach ds = new QuanLiDanhSach(); int option; do { ds.menu();

System.out.print("Nhap lua chon: "); option = sc.nextInt(); sc.nextLine(); switch (option) { case 1:

System.out.println(" NHAP THONG TIN: "); ds.nhapDS(); break; case 2:

System.out.println(" XUAT THONG TIN: "); ds.xuatDS(); break; case 3:

System.out.println("Luu thanh cong"); ds.luuFile(); break; case 4: ds.docFile();

System.out.println("Doc thanh cong"); break; case 5:

System.out.println(" THEM PHIEU MOI: "); ds.themPhieuDiemMoi(); break; case 6:

System.out.println(" XOA PHIEU: "); ds.xoaPhieu(); break; case 7:

System.out.println(" TIM KIEM PHIEU: "); ds.timKiemPhieuTheoMa(); break; case 8:

System.out.println(" SUA THONG TIN PHIEU: "); ds.suaPhieu(); break; case 9:

System.out.println(" IN PHIEU DIEM CO DIEM CUOI KI LON HON 8: "); ds.inPhieuDiemCKLonHon8(); break; case 10:

System.out.println(" XUAT THONG TIN SINH VIEN: "); ds.xuatThongTinSinhVienTrongPhieu(); break; case 11:

System.out.println(" XUAT THONG TIN CAN BO: "); ds.xuatThongTinCanBoTrongPhieu(); break; default: throw new IllegalArgumentException("Unexpected value: " + option); }

KIỂM THỬ - LẬP BỘ TEST

- Xuất thông tin chi tiết sinh viên, cán bộ

- Thoát ĐÁNH GIÁ CÔNG VIỆC VÀ KẾT LUẬN

Qua quá trình thực hiện, em đã đạt được một số kết quả đáng kể:

Để xây dựng một hệ thống quản lý hiệu quả, việc nắm vững kiến thức lý thuyết về lập trình hướng đối tượng là rất quan trọng Kiến thức này giúp tôi hiểu rõ hơn về quy trình phát triển và tối ưu hóa các ứng dụng, từ đó nâng cao khả năng lập trình và giải quyết vấn đề.

Áp dụng kiến thức lý thuyết vào thực tiễn là một bước tiến quan trọng trong việc rèn luyện kỹ năng thực hành Qua bài tập thiết kế và triển khai hệ thống quản lý phiếu điểm sinh viên, em đã hiểu rõ hơn về những thách thức và cơ hội trong việc ứng dụng công nghệ thông tin trong quản lý giáo dục.

Bài tập lớn chắc chắn còn nhiều sai sót nhưng em sẽ cố gắng hoàn thiện một cách tốt nhất!

Ngày đăng: 14/02/2025, 15:51

TỪ KHÓA LIÊN QUAN