java基础,学生管理

大概写了一个简单的管理系统,命名为修仙1.0
添加内容,删除内容,查看内容

HTML包下的
IndexHTML,启动页

package html;

import model.HomeModel;
import tool.ScannerTool;

import java.util.ArrayList;

public class IndexHTML {

    public static void main(String[] args) {

        RecuitHTML re = new RecuitHTML();
        System.out.println("修仙模拟器1.0");
        System.out.println("输入你的门派:");
        String home = ScannerTool.getString();;

        System.out.println("目前支持:");


        while (true){
            System.out.println("输入你的操作序号:");
            System.out.println("1.增加宗门弟子");
            System.out.println("2.开除宗门弟子");
            System.out.println("3.查看所有弟子");
            System.out.println("0.关闭模拟器");
            int key = ScannerTool.getInt();
            switch(key){
                case 1:
                   re.addPeople();
                   break;
                case 2:
                    re.update();
                    break;
                case 3:
                    System.out.println(home+"宗门弟子如下:");
                    re.queryPeople();
                    break;
                 default:
                    break;
            }
            if (key==0){
                System.out.println("退出系统成功");
                break;
            }
        }
    }
}

HTML包下的
RecuitHTML,放一些操作

package html;

import com.sun.jdi.event.StepEvent;
import model.People;
import tool.ScannerTool;

import java.lang.ref.SoftReference;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.regex.Pattern;

public class RecuitHTML {


    IndexHTML in = new IndexHTML();

    //一个招聘的页面,可以把收来的人写进系统里面
    ArrayList<People> peopleList = new ArrayList<People>();


    //添加弟子
    public void addPeople(){


        System.out.println("请输入弟子的编号");
        int num = ScannerTool.getInt();

        System.out.println("请输入添加弟子的姓名:");
        String name = ScannerTool.getString();

        System.out.println("请输入添加弟子的性别:");
        System.out.println("1——————————男");
        System.out.println("2——————————女");
        int sexInput= ScannerTool.getInt();
        String sex = null;
        if (sexInput==1){
            sex="男";
        }else {
            sex="女";
        }

        System.out.println("请输入添加弟子的年龄:");
        int age = ScannerTool.getInt();

        System.out.println("请输入添加弟子的修为:");
        System.out.println("1.练气");
        System.out.println("2.筑基");
        System.out.println("3.金丹");
        int key=ScannerTool.getInt();
        String money = "";
        switch(key){
            case 1:
                money="练气";
               break;
            case 2:
                money="筑基";
                break;
            case 3:
                money="金丹";
                break;
             default:
                 System.out.println("1.0版本内不存妖孽");
                break;
        }
        People p = new People(num,name,sex,age,money);
        peopleList.add(p);
        System.out.println("弟子添加成功");
    }
    public void queryPeople(){
        for (People p:peopleList){
            System.out.println("编号"+p.getNum());
            System.out.println("姓名:"+p.getName());
            System.out.println("性别:"+p.getSex());
            System.out.println("年龄:"+p.getAge());
            System.out.println("_____________________");
        }
    }


    public void updatePeople(){

    }
    public void update(){
        System.out.println("请输入要开除弟子的行序:");
        int row   =ScannerTool.getInt();
        peopleList.remove(row-1);
    }
}

model包下的一些模板

`package model;

public class HomeModel {
String name;

public HomeModel(){}
public HomeModel(String name) {
    this.name = name;
}

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

}
`

package model;

public class People {
    int num;
    private String name;
    private String sex;
    private int age;
    private String money;

    public People() {
    }

    public People(int num, String name, String sex, int age, String money) {
        this.num = num;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.money = money;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getMoney() {
        return money;
    }

    public void setMoney(String money) {
        this.money = money;
    }
}


Tool包,用来接收数据的Scanner
`package tool;

package tool;

import java.util.Scanner;

public class ScannerTool {
    private static Scanner scanner = new Scanner(System.in);
    public static String getString(){return scanner.next();}
    public static int getInt(){return scanner.nextInt();}
    public static double getDouble(){return scanner.nextDouble();}
}

一个简单的信息管理,
1.写入门派的时候想放到方法add里面去写,但是add循环
那样又不好看,想要写一遍就可以的门派名字。
最后写到主页了,直接调用简单明了
2.删除学生想用获得学生学号来写,但是获得了数据不知道怎么获得数据排名之类的,用行序总感觉不是很好看

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值