职坐标 选课系统整体框架 参考
2016-02-21 18:58
323 查看
package com.iotekclass.ht.view;
import java.util.Scanner;
import com.iotekclass.ht.beans.Student;
import com.iotekclass.ht.dao.StudentDao;
import com.iotekclass.ht.dao.impl.IStudentDao;
public class StudentMenu {
private IStudentDao studentDao;
private Scanner input = null;
public StudentMenu() {
super();
this.studentDao = new StudentDao();
this.input = new Scanner(System.in);
}
/**
* 开始运行系统
*/
public void startSystem() {
mainMenu();
}
/**
* 主菜单
*/
private void mainMenu() {
System.out.println("===========================");
System.out.println("1.新增学生");
System.out.println("2.删除学生");
System.out.println("3.修改学生");
System.out.println("4.查询学生");
System.out.println("5.显示全部");
System.out.println("6.退出");
System.out.println("===========================");
System.out.println("请选择:");
int choice = input.nextInt();
switch (choice) {
case 1:
insert();
break;
case 2:
delete();
break;
case 3:
update();
break;
case 4:
search();
break;
case 5:
showAll();
break;
case 6:
System.out.println("====>您已经退出!谢谢~");
System.exit(0);// 正常退出程序
break;
default:
System.out.println("====>输入错误,系统终止");
System.exit(-1);
break;
}
}
/*
添加一个学员信息
*/
private void insert() {
returnMain();
}
/*按学号删除一个学员信息*/
private void delete(){
returnMain();
}
/*按学号更新学员的信息*/
priate void update(){
returnMain();
}
/*按学号查询学员信息*/
private void search() {
System.out.println("====>查询学生");
System.out.println("请输入编号");
int sid = input.nextInt();
Student student = studentDao.search(sid); //简单工厂模式;
if (null != student) {
System.out.println("====>查询成功"+student.toString());
}else {
System.out.println("====>查询失败");
}
returnMain();
}
/*查询所有学员信息*/
private void showAll(){
Student[] students = studentDao.search();
if (null != students && students.length != 0) {
for (Student student : students) { //三目运算法则 轮询
if (student != null) {//不为空
//打印学生信息
System.out.println(student.toString());
}
}
}
returnMain();
}
/**
* 输入0返回功能
*/
private void returnMain() {
}
}
import java.util.Scanner;
import com.iotekclass.ht.beans.Student;
import com.iotekclass.ht.dao.StudentDao;
import com.iotekclass.ht.dao.impl.IStudentDao;
public class StudentMenu {
private IStudentDao studentDao;
private Scanner input = null;
public StudentMenu() {
super();
this.studentDao = new StudentDao();
this.input = new Scanner(System.in);
}
/**
* 开始运行系统
*/
public void startSystem() {
mainMenu();
}
/**
* 主菜单
*/
private void mainMenu() {
System.out.println("===========================");
System.out.println("1.新增学生");
System.out.println("2.删除学生");
System.out.println("3.修改学生");
System.out.println("4.查询学生");
System.out.println("5.显示全部");
System.out.println("6.退出");
System.out.println("===========================");
System.out.println("请选择:");
int choice = input.nextInt();
switch (choice) {
case 1:
insert();
break;
case 2:
delete();
break;
case 3:
update();
break;
case 4:
search();
break;
case 5:
showAll();
break;
case 6:
System.out.println("====>您已经退出!谢谢~");
System.exit(0);// 正常退出程序
break;
default:
System.out.println("====>输入错误,系统终止");
System.exit(-1);
break;
}
}
/*
添加一个学员信息
*/
private void insert() {
returnMain();
}
/*按学号删除一个学员信息*/
private void delete(){
returnMain();
}
/*按学号更新学员的信息*/
priate void update(){
returnMain();
}
/*按学号查询学员信息*/
private void search() {
System.out.println("====>查询学生");
System.out.println("请输入编号");
int sid = input.nextInt();
Student student = studentDao.search(sid); //简单工厂模式;
if (null != student) {
System.out.println("====>查询成功"+student.toString());
}else {
System.out.println("====>查询失败");
}
returnMain();
}
/*查询所有学员信息*/
private void showAll(){
Student[] students = studentDao.search();
if (null != students && students.length != 0) {
for (Student student : students) { //三目运算法则 轮询
if (student != null) {//不为空
//打印学生信息
System.out.println(student.toString());
}
}
}
returnMain();
}
/**
* 输入0返回功能
*/
private void returnMain() {
}
}
相关文章推荐
- 算法精讲学习笔记 字符串
- 数组(二维数组)
- 自定义控件分析1
- Eclipse相关问题
- mysql - 汇总函数
- SWIFT 闭包的简单使用
- webStorm:正确的代码也提示绿色下划线的解决方法
- Leetcode 258
- 九大排序算法再总结
- sort c++ double
- CGI/FastCGI学习-篇一
- xcode怎么把自定义代码添加到代码库CodeSnippets
- Android中ListView适配器里区分不同按钮的点击事件
- os_time.c
- Android Wear 进阶 2.1 Creating and Running a Wearable App 创建和运行手表应用
- java安全 ——JAAS(Java 认证和授权服务)开发指南
- 拷贝构造函数与析构顺序
- android图片查看(1)
- GCD下的几种实现同步的方式
- IOS中消息的传递机制(delegate,block,通知,KVO)