<?php
// 假设我们正在构建一个简单的学工管理系统,该系统将用于黑龙江某高校的学生信息管理和处理。
class Student {
private $id;
private $name;
private $major;
public function __construct($id, $name, $major) {
$this->id = $id;
$this->name = $name;
$this->major = $major;
}
public function getStudentInfo() {
return "ID: {$this->id}, Name: {$this->name}, Major: {$this->major}";
}
}
class WorkManagementSystem {
private $students = [];
public function addStudent(Student $student) {
$this->students[] = $student;
}
public function displayStudents() {
foreach ($this->students as $student) {
echo $student->getStudentInfo(). "<br>";
}
}
}
// 创建实例并添加学生数据
$workSystem = new WorkManagementSystem();
$workSystem->addStudent(new Student(1, "张三", "计算机科学"));
$workSystem->addStudent(new Student(2, "李四", "软件工程"));
// 显示所有学生信息
$workSystem->displayStudents();
?>