项目一
package date528;
import java.util.Scanner;
public class Date528HomeWork {
static Money money = new Money();
static Scanner in =new Scanner(http://System.in);
public static void main(String[] args) {
// Test();//第一题
// money();//第二题
// new printer(9);//第三题
// new printer(9,12);
// new printer(9,122,3);
int a = 4;
int b = 6;
fun3(a,b);
Students stu1 =new Students();
stu1.setName("李四");stu1.setId(5);
Students stu2 = new Students();
stu2.setName("张三");stu2.setId(23);
fun3(stu1,stu2);
System.out.println("输出结果为\na="+a+"\tb="+b+"\nstu1="+stu1+"\tstu2="+stu2);
}
public static void Test() {
Students st = new Students();
st.learn();
}
public static void money(){
if(money.getUsername()==null) {
fun2();
}else {
System.out.println("欢迎进入存钱取钱功能,当前系统用户 "+"位\n输入您的姓名继续,");
String name = in.next();
money.setUsername(name);
fun2();
}
}
public static void fun2(){
System.out.println("欢迎"+money.getUsername()+"您的余额是"+money.getMoney()+"输入正确的数字选择功能\n1:存钱,\t2:取钱\t3退出");
int next = in.nextInt();
switch (next) {
case 1 :
int x = in.nextInt();
money.save(x);
break;
case 2:
System.out.println("输入取的金额");
int x1 = in.nextInt();
money.withdraw(x1);
break;
case 3:
System.exit(0);
default:
System.out.println("输入有误");
money();
}
}
public static void fun3(Object obj1,Object obj2) {
if(obj1 instanceof Students) {
Students temp = (Students) obj1;
((Students) obj1).setName(((Students) obj2).getName());
((Students) obj1).setId(((Students) obj2).getId());
((Students) obj1).setAge(((Students) obj2).getAge());
((Students) obj1).setGender(((Students) obj2).getGender());
((Students) obj2).setName(((Students) temp).getName());
((Students) obj2).setId(((Students) temp).getId());
((Students) obj2).setAge(((Students) temp).getAge());
((Students) obj2).setGender(((Students) temp).getGender());
}else {
Object temp = obj2;
obj2 = obj1;
obj1 = temp;
}
}
}