#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include"list.h"
#include"user.h"
#include"student.h"
#include"teacher.h"
#include"administrator.h"
void data_init(User user_head, Student stu_head, Teacher tch_head, Admin admin_head);
int main()
{
User user_head;
Student stu_head;
Teacher tch_head;
Admin admin_head;
User *login;
int quit_system;
data_init( user_head, stu_head, tch_head, admin_head);
do
{
login= user_login(user_head);
if(login==NULL)
{
return(0);
}
switch(login->user_kind)
{
case 1:
stu_do(login, stu_head);
break;
case 2:
teacher_do(login, stu_head);
break;
case 3:
admin_do(login,user_head, stu_head, tch_head, admin_head);
break;
default:
break;
}
printf("继续请输入1,退出系统输入0\n");
scanf("%d",&quit_system);
}while(quit_system);
return(0);
}
void data_init(User user_head, Student stu_head, Teacher tch_head, Admin admin_head)
{
Student *p_stu;
Teacher *p_tea;
Admin *p_admin;
INIT_LIST_HEAD(&stu_head.stu_list);//学生链表头初始化
INIT_LIST_HEAD(&stu_head.user.user_list);
INIT_LIST_HEAD(&tch_head.tch_list);//老师链表头初始化
INIT_LIST_HEAD(&tch_head.user.user_list);
INIT_LIST_HEAD(&admin_head.admin_list);//管理员链表头初始化
INIT_LIST_HEAD(&admin_head.user.user_list);
INIT_LIST_HEAD(&user_head.user_list);//用户链表头初始化
//用户初始数据
//学生初始数据
p_stu =(Student *)malloc(STUDENT_LEN);
strcpy(p_stu->user.password,"1111");
strcpy(p_stu->user.name,"student");
p_stu->score= 90;
p_stu->user.user_kind= 1;
list_add(&(p_stu->stu_list), &(stu_head.stu_list));
list_add(&(p_stu->user.user_list), &(user_head.user_list));
//老师初始数据
p_tea =(Teacher *)malloc(TEACHER_LEN);
strcpy(p_tea->user.password,"1111");
strcpy(p_tea->user.name,"teacher");
p_tea->user.user_kind= 2;
list_add(&(p_tea->tch_list), &(tch_head.tch_list));
list_add(&(p_tea->user.user_list), &(user_head.user_list));
//管理员初始数据
p_admin =(Admin *)malloc(ADMIN_LEN);
strcpy(p_admin->user.password,"1111");
strcpy(p_admin->user.name,"administrator");
p_admin->user.user_kind= 3;
list_add(&(p_admin->admin_list), &(admin_head.admin_list));
list_add(&(p_admin->user.user_list), &(user_head.user_list));
}