69期-Java SE-007_面向对象-1-001-002
2020-12-13 06:14
标签:输入 span java ble img i+1 set student OLE Student.java Test.java User.java UserTest.java 69期-Java SE-007_面向对象-1-001-002 标签:输入 span java ble img i+1 set student OLE 原文地址:https://www.cnblogs.com/HiJackykun/p/11172075.htmlpublic class Student {
//定义属性
int id;
String name;
int age;
int userFirstName;
double myScore;
//定义方法
public static int add(int num1,int num2) {
return num1+num2;
}
public static void add2(int num1,int num2) {
System.out.println(num1+num2);
}
public static void show() {
System.out.println("Hello World");
}
public static void main(String[] args) {
int num = add(1,1);
add2(1,1);
}
/**
* 无参构造
*/
public Student() {
}
/**
* 有参构造
*/
public Student(int num) {
}
public void test() {
}
}
import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//初始化用户名
String[] nameArray = {"张三","李四","王五","小明"};
//初始化用户年龄
int[] ageArray = {22,23,20,22};
//初始化用户状态
String[] stateArray = {"正常","正常","正常","正常"};
Scanner scanner = new Scanner(System.in);
int num;
String name;
int age;
int index = 0;
boolean flag;
do {
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.print("请选择:");
num = scanner.nextInt();
switch(num) {
case 1:
System.out.println("------ 查询用户 ------");
System.out.println("编号\t\t姓名\t\t年龄\t\t状态\t\t");
for(int i=0;i
public class User {
//属性
private long id;
private String name;
private char gender;
private String password;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
this.gender = gender;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public static void show() {
System.out.println("用户信息如下:");
// System.out.println(this.id);
// System.out.println(this.name);
// System.out.println(this.gender);
// System.out.println(this.password);
}
}
public class UserTest {
public static void main(String[] args) {
// User user = new User();
// user.setId(-10);
// user.setName("张三");
// user.setGender(‘男‘);
// user.setPassword("123123");
// user.show();
User.show();
}
}
文章标题:69期-Java SE-007_面向对象-1-001-002
文章链接:http://soscw.com/essay/32744.html