package sims.run;
import sims.dao.CourseDao;
import sims.dao.StuDao;
import sims.dao.TeaDao;
import sims.entity.*;
import sims.po.LoginPO;
import java.util.Scanner;
public class Opt {
/**
* 通过控制台输入 获取stu实体相关数据
*
* @param id
* @return
*/
public static Stu get(Integer id) {
Stu stu = new Stu();
stu.setId(id);
while (true) {
System.out.println("请输入学号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setNum(tmp);
break;
}
}
while (true) {
System.out.println("请输入登录密码");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setPassword(tmp);
break;
}
}
while (true) {
System.out.println("请输入姓名");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setName(tmp);
break;
}
}
while (true) {
System.out.println("请输入年龄");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setAge(Integer.parseInt(tmp));
break;
}
}
while (true) {
System.out.println("请输入性别");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setSex(tmp);
break;
}
}
while (true) {
System.out.println("请输入系别");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setXb(tmp);
break;
}
}
while (true) {
System.out.println("请输入专业");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
stu.setZy(tmp);
break;
}
}
return stu;
}
/**
* 通过控制台输入 获取tea实体相关数据
*
* @param id
* @return
*/
public static Tea getTea(Integer id) {
Tea tea = new Tea();
tea.setId(id);
while (true) {
System.out.println("请输入教师号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setNum(tmp);
break;
}
}
while (true) {
System.out.println("请输入登录密码");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setPassword(tmp);
break;
}
}
while (true) {
System.out.println("请输入姓名");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setName(tmp);
break;
}
}
while (true) {
System.out.println("请输入年龄");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setAge(Integer.parseInt(tmp));
break;
}
}
while (true) {
System.out.println("请输入性别");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setSex(tmp);
break;
}
}
while (true) {
System.out.println("请输入系别");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
tea.setXb(tmp);
break;
}
}
return tea;
}
/**
* 通过控制台输入 获取course实体相关数据
*
* @param id
* @return
*/
public static Course getCourse(Integer id) {
Course course = new Course();
course.setId(id);
while (true) {
System.out.println("请输入课程号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
course.setCode(tmp);
break;
}
}
while (true) {
System.out.println("请输入课程名");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
course.setName(tmp);
break;
}
}
while (true) {
System.out.println("请输入学分");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
course.setScore(Integer.parseInt(tmp));
break;
}
}
while (true) {
System.out.println("请输入课时");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
course.setTimes(Integer.parseInt(tmp));
break;
}
}
return course;
}
/**
* 通过控制台输入 获取course实体相关数据
*
* @return
*/
public static TeaCourse getTeaCourse() throws Exception {
TeaCourse teaCourse = new TeaCourse();
while (true) {
System.out.println("请输入课程号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
Course course = CourseDao.get(tmp);
if (course.getId() == null) {
System.out.println("课程不存在");
} else {
teaCourse.setCourseId(course.getId());
break;
}
}
}
while (true) {
System.out.println("请输入教师号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
Tea tea = TeaDao.get(tmp);
if (tea.getId() == null) {
System.out.println("教师不存在");
} else {
teaCourse.setTeaId(tea.getId());
break;
}
}
}
return teaCourse;
}
/**
* 通过控制台输入 获取course实体相关数据
*
* @return
*/
public static StuCourse getStuCourse() throws Exception {
StuCourse stuCourse = new StuCourse();
while (true) {
System.out.println("请输入课程号");
Scanner scanner = new Scanner(System.in);
String tmp = scanner.next();
if (tmp != null && !tmp.equals("")) {
Course course = CourseDao.get(tmp);
if (course.getId() == null) {
System.out.println("课程不存在");