ing

package studentmangera;
import java.util.Scanner;
import java.util.ArrayList;

public class studentmanger1 {
/**
* @param args
*/
public static void main(String[] args)
{
ArrayList<student1> array = new ArrayList<student1>();
while(true) {
Scanner sc = new Scanner(System.in);
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("输入你的选择");

String line = sc.nextLine();

switch(line)
{
case "1":
addstudent(array);
// System.out.println("添加学生");
break;
case "2":
System.out.println("删除学生");
break;
case "3":
System.out.println("修改学生");
break;
case "4":
System.out.println("查看所有学生");
break;
case "5":
System.out.println("谢谢使用");
System.exit(0);//java虚拟机退出
}
}
}
public static void addstudent(ArrayList<student1> array)
{
//录入学生对象
Scanner sc = new Scanner(System.in);

System.out.println("请输入学生学号");
String id = sc.nextLine();
System.out.println("请输入学生姓名");
String name = sc.nextLine();
System.out.println("请输入学生年龄");
String age = sc.nextLine();
System.out.println("请输入学生地址");
String address = sc.nextLine();
//创建学生变量
student1 s = new student1();
s.setId(id);
s.setName(name);
s.setAge(age);
s.setAddress(address);
//将学生添加到集合中去
array.add(s);

//给出提示
System.out.println("添加学生成功");
}
public static void findAllStudent(ArrayList<student1> array)
{

}
}

 

package studentmangera;

public class student1 {

private String id;
private String name;
private String age;
private String address;
public student1() {
super();
// TODO Auto-generated constructor stub
}
public student1(String id, String name, String age, String address) {
super();
this.id = id;
this.name = name;
this.age = age;
this.address = address;
}
/**
* @return the id
*/
public String getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the age
*/
public String getAge() {
return age;
}
/**
* @param age the age to set
*/
public void setAge(String age) {
this.age = age;
}
/**
* @return the address
*/
public String getAddress() {
return address;
}
/**
* @param address the address to set
*/
public void setAddress(String address) {
this.address = address;
}

}

上一篇:字节跳动后端开发一面(持续更新ing)


下一篇:物流项目问题ing