将每个*****到*********之间的代码拷贝后缀为.Java文件,然后导入到MyEclipse里面即可..作者:梅强强(QQ:826219395)
******************
import java.util.zip.DataFormatException;
public abstract class Person implements IMyExtends{
private int pid; //成员编号
private String pname; //成员姓名
private int page; //成员年龄
private byte psex; //成员性别
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public byte getPsex() {
return psex;
}
public void setPsex(byte psex) {
this.psex = psex;
}
//方法空实现
public abstract void callCard() throws DataFormatException;
//方法空实现
public abstract void display();
}
*********************
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class InputOperator implements IDataRead {
private Student[] stu;
private Teacher[] tea;
private static int stuLength; //记录学员全局个数
private static int teaLength; //记录教师全局个数
public Student[] getStu() {
return stu;
}
public Teacher[] getTea() {
return tea;
}
public void stuInput(){
int lengths = 5;
int flag = 0;
int i = 0;
Scanner scan = new Scanner(System.in);
stu = new Student[lengths];
do {
stu[i] = new Student();
System.out.println();
System.out.printf("请输入第%d个学员的信息\n", i + 1);
System.out.print("学员编号:");
stu[i].setPid(scan.nextInt());
System.out.print("学员姓名:");
stu[i].setPname(scan.next());
System.out.print("学员年龄:");
stu[i].setPage(scan.nextInt());
System.out.print("学员性别(1:男 0:女):");
stu[i].setPsex(scan.nextByte());
System.out.print("学员成绩:");
stu[i].setCourse(scan.nextFloat());
i++;
System.out.println();
System.out.print("是否继续?<1:继续 0:返回>:");
flag = scan.nextInt();
} while (flag == 1);
stuLength = i; //记录学员个数
}
public void teaInput(){
int lengths = 0;
int flag = 0;
int i = 0;
Scanner scan = new Scanner(System.in);
System.out.println("请输入教师的个数:");
lengths = scan.nextInt();
tea = new Teacher[lengths];
do {
tea[i] = new Teacher();
System.out.println();
System.out.printf("请输入第%d个教师的信息\n", i + 1);
System.out.print("教师编号:");
tea[i].setPid(scan.nextInt());
System.out.print("教师姓名:");
tea[i].setPname(scan.next());
System.out.print("教师年龄:");
tea[i].setPage(scan.nextInt());
System.out.print("教师性别(1:男 0:女):");
tea[i].setPsex(scan.nextByte());
System.out.print("教师工资:");
tea[i].setSalary(scan.nextFloat());
i++;
System.out.println();
System.out.print("是否继续?<1:继续 0:返回>:");
flag = scan.nextInt();
} while (flag == 1);
teaLength = i; //记录教师个数
}
public void stuRead(){
BufferedReader br = null;
try {
String str;
int lengths = this.getLength("e:\\Student.java");
br = new BufferedReader(new FileReader("e:\\Student.java"));
stu = new Student[lengths];
for (int i=0;i<lengths;i++) {
stu[i] = new Student();
if((str=br.readLine())!=null){
stu[i].setPid(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
stu[i].setPname(str);
}
if((str=br.readLine())!=null){
stu[i].setPage(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
stu[i].setPsex(Byte.parseByte(str));
}
if((str=br.readLine())!=null){
stu[i].setCourse(Float.parseFloat(str));
}
}
System.out.println("");
System.out.println("学员数据正在加载,请稍后......");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!学员数据加载成功,请继续操作!");
System.out.println("");
}catch (IOException e) {
System.out.println("找不到文件");
}
}
public void teaRead(){
BufferedReader br = null;
try {
String str;
int lengths = this.getLength("e:\\Teacher.java");
br = new BufferedReader(new FileReader("e:\\Teacher.java"));
tea = new Teacher[lengths];
for (int i=0;i<lengths;i++) {
tea[i] = new Teacher();
if((str=br.readLine())!=null){
tea[i].setPid(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
tea[i].setPname(str);
}
if((str=br.readLine())!=null){
tea[i].setPage(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
tea[i].setPsex(Byte.parseByte(str));
}
if((str=br.readLine())!=null){
tea[i].setSalary(Float.parseFloat(str));
}
}
System.err.println();
System.out.println("");
System.out.println("教师数据正在加载,请稍后......");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!教师数据加载成功,请继续操作!");
System.out.println("");
}catch (IOException e) {
System.out.println("找不到文件");
}
}
public int getLength(String path){
String str;
int lengths = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(path));
while((str=br.readLine())!=null){
lengths++;
}
lengths = lengths/5;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return lengths;
}
}
******************************
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class OutputOperator implements IDataWrite {
private Student[] stu;
private Teacher[] tea;
private InputOperator input;
public OutputOperator(){
}
public OutputOperator(InputOperator input){
this.input = input;
}
public void stuOutput() {
String sexo;
Scanner scan = new Scanner(System.in);
stu = input.getStu();
System.out.println();
System.out.println("\t\t\t学员信息输出");
System.out.println("\t*****************************************");
System.out.println("\t编号\t姓名\t年龄\t性别\t成绩");
for (int i = 0; i < stu.length; i++) {
// 排除空值
if (stu[i] != null) {
if (stu[i].getPsex() == 1) {
sexo = "男";
}else {
sexo = "女";
}
System.out.printf("\t%d\t%s\t%d\t%s\t%.2f\n", stu[i].getPid(),stu[i].getPname(),
stu[i].getPage(),sexo,stu[i].getCourse());
}
}
}
public void teaOutput() {
String sexo;
Scanner scan = new Scanner(System.in);
tea = input.getTea();
if(tea == null){
System.out.println("当前没有教师信息输出...");
}else{
System.out.println();
System.out.println("\t\t\t教师信息输出");
System.out.println("\t*****************************************");
System.out.println("\t编号\t姓名\t年龄\t性别\t工资");
for (int i = 0; i < tea.length; i++) {
// 排除空值
if (tea[i] != null) {
if (tea[i].getPsex() == 1) {
sexo = "男";
}else {
sexo = "女";
}
System.out.printf("\t%d\t%s\t%d\t%s\t%.2f\n", tea[i].getPid(),tea[i].getPname(),
tea[i].getPage(),sexo,tea[i].getSalary());
}
}
}
}
public void stuWrite(){
BufferedWriter bw = null;
stu = input.getStu();
try {
bw = new BufferedWriter(new FileWriter("e:\\Student.java"));
String []s = new String[stu.length];
for(int i=0;i<stu.length;i++){
if(stu[i] != null){
s[i] = stu[i].getPid() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPname();
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPage() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPsex() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getCourse() + "";
bw.write(s[i]);
bw.newLine();
}
}
bw.flush();
System.out.println("");
System.out.println("学员数据正在保存,请稍后......");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!学员数据保存成功,请继续操作!");
System.out.println("");
} catch (IOException e) {
e.printStackTrace();
}
}
public void teaWrite(){
BufferedWriter bw = null;
tea = input.getTea();
try {
bw = new BufferedWriter(new FileWriter("e:\\Teacher.java"));
String []s = new String[tea.length];
for(int i=0;i<tea.length;i++){
if(tea[i] != null){
s[i] = tea[i].getPid() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPname();
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPage() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPsex() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getSalary() + "";
bw.write(s[i]);
bw.newLine();
}
}
bw.flush();
System.out.println("");
System.out.println("教师数据正在保存,请稍后......");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!教师数据保存成功,请继续操作!");
System.out.println("");
} catch (IOException e) {
e.printStackTrace();
}
}
}
***************************
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.zip.DataFormatException;
public class Student extends Person{
private float course; //学员成绩
private static InputOperator input;
private static OutputOperator output;
public float getCourse() {
return course;
}
public void setCourse(float course) {
this.course = course;
}
@Override
public void display() {
int xs;// 定义选择
Scanner scans = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t学员管理菜单");
System.out.println("\t******************************************");
System.out.println("\t1.输入信息\t2.输出信息\t3.学员打卡");
System.out.println("\t4.保存信息\t5.读取信息\t0.返回主页");
System.out.println();
System.out.print(" 请选择:");
xs = scans.nextInt();// 输入选择
if (xs == 1) {
input = new InputOperator();
input.stuInput(); //学员信息输入
this.display();
}else if (xs == 2) {
output = new OutputOperator(input);
output.stuOutput(); //学员信息输出
this.display();
}else if (xs == 3) {
try {
this.callCard(); //学员打卡
} catch (DataFormatException e) {
e.printStackTrace();
}
this.display();
}else if (xs == 4) {
output = new OutputOperator(input);
output.stuWrite(); //学员信息保存
this.display();
}else if (xs == 5) {
input = new InputOperator();
input.stuRead(); //学员信息读取
this.display();
}else {
return;
}
}
@Override
public void callCard() throws DataFormatException{
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd E a 'at' hh:mm:ss");
Student[] stu = input.getStu();
for (int i = 0; i < stu.length; i++) {
if(stu[i] != null){
System.out.println("学员打卡ID: " + stu[i].getPid());
System.out.println("学员打卡时间: " + formatter.format(dNow));
}
}
}
}
*********************
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.zip.DataFormatException;
public class Teacher extends Person{
private float salary;
private static InputOperator input;
private static OutputOperator output;
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public void display() {
int xt;// 定义选择
Scanner scans = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t教师管理菜单");
System.out.println("\t******************************************");
System.out.println("\t1.输入信息\t2.输出信息\t3.教师打卡");
System.out.println("\t4.保存信息\t5.读取信息\t0.返回主页");
System.out.println();
System.out.print(" 请选择:");
xt = scans.nextInt();// 输入选择
if (xt == 1) {
input = new InputOperator();
input.teaInput(); //教师信息输入
this.display();
}else if (xt == 2) {
output = new OutputOperator(input);
output.teaOutput(); //教师信息输出
this.display();
}else if (xt == 3) {
try {
this.callCard(); //教师打卡
} catch (DataFormatException e) {
e.printStackTrace();
}
this.display();
}else if (xt == 4) {
output = new OutputOperator(input);
output.teaWrite(); //教师信息保存
this.display();
}else if (xt == 5) {
input = new InputOperator();
input.teaRead(); //教师信息读取
this.display();
}else {
return;
}
}
@Override
public void callCard() throws DataFormatException{
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd E a 'at' hh:mm:ss");
Teacher[] tea = input.getTea();
for (int i = 0; i < tea.length; i++) {
if(tea[i] != null){
System.out.println("教师打卡ID: " + tea[i].getPid());
System.out.println("教师打卡时间: " + formatter.format(dNow));
}
}
}
}
*************************
import java.util.zip.DataFormatException;
public interface IMyExtends {
public void display(); //菜单方法
public void callCard() throws DataFormatException; //打卡方法
}
***************************
public interface IDataRead {
public void stuRead(); //读取学员数据方法
public void teaRead(); //读取教师数据方法
}
*************************
public interface IDataWrite {
public void stuWrite(); //保存学员数据方法
public void teaWrite(); //保存教师数据方法
}
*************************
import java.util.Scanner;
public class SystemMenu {
private InputOperator input;
private OutputOperator output;
private Student s;
private Teacher t;
public void display(){
int x;// 定义选择
Scanner scan = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t信息管理系统");
System.out.println("\t*****************************************");
System.out.println("\t1.学员管理\t2.教师管理\t0.程序退出");
System.out.println();
System.out.print("\t请选择:");
x = scan.nextInt();// 输入选择
if (x == 1) {
s = new Student();
s.display();
this.display();
}else if (x == 2) {
t = new Teacher();
t.display();
this.display();
}else {
System.out.println();
System.out.println("\t欢迎下次使用,再见!");
}
}
}
***********************************
public class TestMain {
public static void main(String[] args) {
SystemMenu menu = new SystemMenu();
menu.display();
}
}
***********************************
******************
import java.util.zip.DataFormatException;
public abstract class Person implements IMyExtends{
private int pid; //成员编号
private String pname; //成员姓名
private int page; //成员年龄
private byte psex; //成员性别
public int getPid() {
return pid;
}
public void setPid(int pid) {
this.pid = pid;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public byte getPsex() {
return psex;
}
public void setPsex(byte psex) {
this.psex = psex;
}
//方法空实现
public abstract void callCard() throws DataFormatException;
//方法空实现
public abstract void display();
}
*********************
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class InputOperator implements IDataRead {
private Student[] stu;
private Teacher[] tea;
private static int stuLength; //记录学员全局个数
private static int teaLength; //记录教师全局个数
public Student[] getStu() {
return stu;
}
public Teacher[] getTea() {
return tea;
}
public void stuInput(){
int lengths = 5;
int flag = 0;
int i = 0;
Scanner scan = new Scanner(System.in);
stu = new Student[lengths];
do {
stu[i] = new Student();
System.out.println();
System.out.printf("请输入第%d个学员的信息\n", i + 1);
System.out.print("学员编号:");
stu[i].setPid(scan.nextInt());
System.out.print("学员姓名:");
stu[i].setPname(scan.next());
System.out.print("学员年龄:");
stu[i].setPage(scan.nextInt());
System.out.print("学员性别(1:男 0:女):");
stu[i].setPsex(scan.nextByte());
System.out.print("学员成绩:");
stu[i].setCourse(scan.nextFloat());
i++;
System.out.println();
System.out.print("是否继续?<1:继续 0:返回>:");
flag = scan.nextInt();
} while (flag == 1);
stuLength = i; //记录学员个数
}
public void teaInput(){
int lengths = 0;
int flag = 0;
int i = 0;
Scanner scan = new Scanner(System.in);
System.out.println("请输入教师的个数:");
lengths = scan.nextInt();
tea = new Teacher[lengths];
do {
tea[i] = new Teacher();
System.out.println();
System.out.printf("请输入第%d个教师的信息\n", i + 1);
System.out.print("教师编号:");
tea[i].setPid(scan.nextInt());
System.out.print("教师姓名:");
tea[i].setPname(scan.next());
System.out.print("教师年龄:");
tea[i].setPage(scan.nextInt());
System.out.print("教师性别(1:男 0:女):");
tea[i].setPsex(scan.nextByte());
System.out.print("教师工资:");
tea[i].setSalary(scan.nextFloat());
i++;
System.out.println();
System.out.print("是否继续?<1:继续 0:返回>:");
flag = scan.nextInt();
} while (flag == 1);
teaLength = i; //记录教师个数
}
public void stuRead(){
BufferedReader br = null;
try {
String str;
int lengths = this.getLength("e:\\Student.java");
br = new BufferedReader(new FileReader("e:\\Student.java"));
stu = new Student[lengths];
for (int i=0;i<lengths;i++) {
stu[i] = new Student();
if((str=br.readLine())!=null){
stu[i].setPid(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
stu[i].setPname(str);
}
if((str=br.readLine())!=null){
stu[i].setPage(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
stu[i].setPsex(Byte.parseByte(str));
}
if((str=br.readLine())!=null){
stu[i].setCourse(Float.parseFloat(str));
}
}
System.out.println("");
System.out.println("学员数据正在加载,请稍后......");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!学员数据加载成功,请继续操作!");
System.out.println("");
}catch (IOException e) {
System.out.println("找不到文件");
}
}
public void teaRead(){
BufferedReader br = null;
try {
String str;
int lengths = this.getLength("e:\\Teacher.java");
br = new BufferedReader(new FileReader("e:\\Teacher.java"));
tea = new Teacher[lengths];
for (int i=0;i<lengths;i++) {
tea[i] = new Teacher();
if((str=br.readLine())!=null){
tea[i].setPid(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
tea[i].setPname(str);
}
if((str=br.readLine())!=null){
tea[i].setPage(Integer.parseInt(str));
}
if((str=br.readLine())!=null){
tea[i].setPsex(Byte.parseByte(str));
}
if((str=br.readLine())!=null){
tea[i].setSalary(Float.parseFloat(str));
}
}
System.err.println();
System.out.println("");
System.out.println("教师数据正在加载,请稍后......");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!教师数据加载成功,请继续操作!");
System.out.println("");
}catch (IOException e) {
System.out.println("找不到文件");
}
}
public int getLength(String path){
String str;
int lengths = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(path));
while((str=br.readLine())!=null){
lengths++;
}
lengths = lengths/5;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return lengths;
}
}
******************************
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class OutputOperator implements IDataWrite {
private Student[] stu;
private Teacher[] tea;
private InputOperator input;
public OutputOperator(){
}
public OutputOperator(InputOperator input){
this.input = input;
}
public void stuOutput() {
String sexo;
Scanner scan = new Scanner(System.in);
stu = input.getStu();
System.out.println();
System.out.println("\t\t\t学员信息输出");
System.out.println("\t*****************************************");
System.out.println("\t编号\t姓名\t年龄\t性别\t成绩");
for (int i = 0; i < stu.length; i++) {
// 排除空值
if (stu[i] != null) {
if (stu[i].getPsex() == 1) {
sexo = "男";
}else {
sexo = "女";
}
System.out.printf("\t%d\t%s\t%d\t%s\t%.2f\n", stu[i].getPid(),stu[i].getPname(),
stu[i].getPage(),sexo,stu[i].getCourse());
}
}
}
public void teaOutput() {
String sexo;
Scanner scan = new Scanner(System.in);
tea = input.getTea();
if(tea == null){
System.out.println("当前没有教师信息输出...");
}else{
System.out.println();
System.out.println("\t\t\t教师信息输出");
System.out.println("\t*****************************************");
System.out.println("\t编号\t姓名\t年龄\t性别\t工资");
for (int i = 0; i < tea.length; i++) {
// 排除空值
if (tea[i] != null) {
if (tea[i].getPsex() == 1) {
sexo = "男";
}else {
sexo = "女";
}
System.out.printf("\t%d\t%s\t%d\t%s\t%.2f\n", tea[i].getPid(),tea[i].getPname(),
tea[i].getPage(),sexo,tea[i].getSalary());
}
}
}
}
public void stuWrite(){
BufferedWriter bw = null;
stu = input.getStu();
try {
bw = new BufferedWriter(new FileWriter("e:\\Student.java"));
String []s = new String[stu.length];
for(int i=0;i<stu.length;i++){
if(stu[i] != null){
s[i] = stu[i].getPid() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPname();
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPage() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getPsex() + "";
bw.write(s[i]);
bw.newLine();
s[i] = stu[i].getCourse() + "";
bw.write(s[i]);
bw.newLine();
}
}
bw.flush();
System.out.println("");
System.out.println("学员数据正在保存,请稍后......");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!学员数据保存成功,请继续操作!");
System.out.println("");
} catch (IOException e) {
e.printStackTrace();
}
}
public void teaWrite(){
BufferedWriter bw = null;
tea = input.getTea();
try {
bw = new BufferedWriter(new FileWriter("e:\\Teacher.java"));
String []s = new String[tea.length];
for(int i=0;i<tea.length;i++){
if(tea[i] != null){
s[i] = tea[i].getPid() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPname();
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPage() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getPsex() + "";
bw.write(s[i]);
bw.newLine();
s[i] = tea[i].getSalary() + "";
bw.write(s[i]);
bw.newLine();
}
}
bw.flush();
System.out.println("");
System.out.println("教师数据正在保存,请稍后......");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("");
System.out.println("耶!教师数据保存成功,请继续操作!");
System.out.println("");
} catch (IOException e) {
e.printStackTrace();
}
}
}
***************************
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.zip.DataFormatException;
public class Student extends Person{
private float course; //学员成绩
private static InputOperator input;
private static OutputOperator output;
public float getCourse() {
return course;
}
public void setCourse(float course) {
this.course = course;
}
@Override
public void display() {
int xs;// 定义选择
Scanner scans = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t学员管理菜单");
System.out.println("\t******************************************");
System.out.println("\t1.输入信息\t2.输出信息\t3.学员打卡");
System.out.println("\t4.保存信息\t5.读取信息\t0.返回主页");
System.out.println();
System.out.print(" 请选择:");
xs = scans.nextInt();// 输入选择
if (xs == 1) {
input = new InputOperator();
input.stuInput(); //学员信息输入
this.display();
}else if (xs == 2) {
output = new OutputOperator(input);
output.stuOutput(); //学员信息输出
this.display();
}else if (xs == 3) {
try {
this.callCard(); //学员打卡
} catch (DataFormatException e) {
e.printStackTrace();
}
this.display();
}else if (xs == 4) {
output = new OutputOperator(input);
output.stuWrite(); //学员信息保存
this.display();
}else if (xs == 5) {
input = new InputOperator();
input.stuRead(); //学员信息读取
this.display();
}else {
return;
}
}
@Override
public void callCard() throws DataFormatException{
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd E a 'at' hh:mm:ss");
Student[] stu = input.getStu();
for (int i = 0; i < stu.length; i++) {
if(stu[i] != null){
System.out.println("学员打卡ID: " + stu[i].getPid());
System.out.println("学员打卡时间: " + formatter.format(dNow));
}
}
}
}
*********************
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
import java.util.zip.DataFormatException;
public class Teacher extends Person{
private float salary;
private static InputOperator input;
private static OutputOperator output;
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
public void display() {
int xt;// 定义选择
Scanner scans = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t教师管理菜单");
System.out.println("\t******************************************");
System.out.println("\t1.输入信息\t2.输出信息\t3.教师打卡");
System.out.println("\t4.保存信息\t5.读取信息\t0.返回主页");
System.out.println();
System.out.print(" 请选择:");
xt = scans.nextInt();// 输入选择
if (xt == 1) {
input = new InputOperator();
input.teaInput(); //教师信息输入
this.display();
}else if (xt == 2) {
output = new OutputOperator(input);
output.teaOutput(); //教师信息输出
this.display();
}else if (xt == 3) {
try {
this.callCard(); //教师打卡
} catch (DataFormatException e) {
e.printStackTrace();
}
this.display();
}else if (xt == 4) {
output = new OutputOperator(input);
output.teaWrite(); //教师信息保存
this.display();
}else if (xt == 5) {
input = new InputOperator();
input.teaRead(); //教师信息读取
this.display();
}else {
return;
}
}
@Override
public void callCard() throws DataFormatException{
Date dNow = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd E a 'at' hh:mm:ss");
Teacher[] tea = input.getTea();
for (int i = 0; i < tea.length; i++) {
if(tea[i] != null){
System.out.println("教师打卡ID: " + tea[i].getPid());
System.out.println("教师打卡时间: " + formatter.format(dNow));
}
}
}
}
*************************
import java.util.zip.DataFormatException;
public interface IMyExtends {
public void display(); //菜单方法
public void callCard() throws DataFormatException; //打卡方法
}
***************************
public interface IDataRead {
public void stuRead(); //读取学员数据方法
public void teaRead(); //读取教师数据方法
}
*************************
public interface IDataWrite {
public void stuWrite(); //保存学员数据方法
public void teaWrite(); //保存教师数据方法
}
*************************
import java.util.Scanner;
public class SystemMenu {
private InputOperator input;
private OutputOperator output;
private Student s;
private Teacher t;
public void display(){
int x;// 定义选择
Scanner scan = new Scanner(System.in);
System.out.println();
System.out.println("\t\t\t信息管理系统");
System.out.println("\t*****************************************");
System.out.println("\t1.学员管理\t2.教师管理\t0.程序退出");
System.out.println();
System.out.print("\t请选择:");
x = scan.nextInt();// 输入选择
if (x == 1) {
s = new Student();
s.display();
this.display();
}else if (x == 2) {
t = new Teacher();
t.display();
this.display();
}else {
System.out.println();
System.out.println("\t欢迎下次使用,再见!");
}
}
}
***********************************
public class TestMain {
public static void main(String[] args) {
SystemMenu menu = new SystemMenu();
menu.display();
}
}
***********************************
- 学生管理系统.rar (13.3 KB)
- 下载次数: 14
相关推荐
Qt基于数据库的学生管理系统源码 Qt基于数据库的学生管理系统源码 Qt基于数据库的学生管理系统源码 Qt基于数据库的学生管理系统源码 Qt基于数据库的学生管理系统源码 Qt基于数据库的学生管理系统源码...
学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理系统代码学生管理...
这是一个基于Python、Qt界面库和MySQL数据库的学生管理系统源码项目。该项目主要涵盖了以下几个重要的IT知识点: 1. **Python编程语言**:Python是一种高级、通用的编程语言,以其简洁明了的语法和强大的库支持而...
【学生管理系统源码】是一个基于.NET框架,使用C#编程语言开发的应用程序,主要用于高校或教育机构进行学生信息管理和日常教学活动的自动化处理。这套系统提供了全面的功能,以提高教育管理效率,减轻行政人员的工作...
《Android应用源码简单的学生管理系统源码》是一个用于学习和参考的开源项目,它展示了如何在Android平台上构建一个基础的学生管理应用程序。这个源码库包含了实现该系统所需的各种组件和功能,是Android开发者尤其...
C语言课程设计-C语言大作业学生管理系统源码,C语言课程设计-C语言学生管理系统源码C语言课程设计-C语言学生管理系统源码C语言课程设计-C语言学生管理系统源码C语言课程设计-C语言学生管理系统源码C语言课程设计-...
python学生管理系统源码文件
spring+springboot+mysql学生管理系统源码,应付大学毕设答辩足够了,部署非常简单。 spring+springboot+mysql学生管理系统源码,应付大学毕设答辩足够了,部署非常简单。 spring+springboot+mysql学生管理系统...
Python界面版学生管理系统源码.zip,Python界面版学生管理系统源码.zip,Python界面版学生管理系统源码.zip,Python界面版学生管理系统源码.zip,Python界面版学生管理系统源码.zip,Python界面版学生管理系统源码....
【C# 学生管理系统源码】是一款基于C#编程语言开发的学生信息管理软件,它主要包含学生管理模块和权限管理模块,旨在提供一个高效、便捷的教育机构内部管理工具。下面将对这两个核心模块进行详细阐述。 首先,学生...
Python+Vue+Django前后端分离的学习学生管理系统源码 Python+Vue+Django前后端分离的学习学生管理系统源码 Python+Vue+Django前后端分离的学习学生管理系统源码 Python+Vue+Django前后端分离的学习学生管理...
学生管理系统源码意味着提供的是程序的原始代码,开发者可以查看、修改和学习。包含数据库表明这个系统不仅有前端用户界面,还集成了后端数据存储功能,用于管理学生数据。数据库可能是关系型的,如SQL Server或...
Java学生管理系统源码是一个非常适合Java初学者实践和学习的项目,它涵盖了基本的数据库操作、MVC设计模式、Swing或JavaFX图形界面等多方面技术。通过分析和理解这个项目,你可以深入学习到Java编程语言的核心特性...
Java学生管理系统源码是一个用于教学和实践的软件项目,它为教育机构或学校提供了一种组织和管理学生信息的有效方式。这个系统的核心是用Java编程语言编写的,它展示了Java在构建实际应用中的强大功能。Java以其跨...