幸运抽奖中,包括了主类,Logo类,注册类,登陆类,抽奖类,以及密码加密类
注意:1,static 的运用
2,一个类对象调用其他类中对象的内存状态需要加深理解
3,密码加密类需要进一步的完善
4,int型转换成数组型的循环方法,以及数组型转换成INT型的循环方法
5,数组的引用类型的运用需要注意
package xingYunChouJiang;
public class XingYunChouJiang {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Logo a = new Logo();
a.show();
}
}
package xingYunChouJiang;
import java.util.Scanner;
public class Logo {
int chose;
void show(){
System.out.println("**************************欢迎进入奖课富翁系统***************************");
System.out.println("1.注册\t2.登陆\t3.抽奖");
System.out.println("***************************************************");
System.out.println("请选择菜单:");
while(1==1){
Scanner input=new Scanner(System.in);
chose=input.nextInt();
if(chose!=1&&chose!=2&&chose!=3){
System.out.println("您输入的命令有误,请从新输入");
continue;
}else{
break;
}
}
ZhuCe logo1=new ZhuCe();
DengLu logo2=new DengLu();
ChouJiang logo3=new ChouJiang();
switch (chose) {
case 1:
logo1.show();
break;
case 2:
logo2.show();
break;
case 3:
logo3.show();
break;
}
}
}
package xingYunChouJiang;
import java.util.Scanner;
public class DengLu {
String name;
int password;
String chose;
void show() {
System.out.println("[奖客富翁系统》登陆]");
Scanner input = new Scanner(System.in);
ZhuCe zhuce = new ZhuCe();
for (int i = 0; i < 3; i++) {
System.out.print("请输入用户名:");
name = input.next();
System.out.print("\n密码:");
password = input.nextInt();
JiaMi denglu=new JiaMi();
password=denglu.jiami(password);
if (name.equals(zhuce.people[0])
&& password==zhuce.password) {
System.out.println("欢迎您:" + name);
break;
} else {
if (i == 2) {
System.out.println("您已经错误了3次,请稍后再试");
}
System.out.println("您还有" + (2 - i) + "次机会");
}
}
System.out.println("继续吗?(y/n)");
chose = input.next();
if (chose.equals("y")) {
Logo denglu = new Logo();
denglu.show();
} else {
System.out.println("系统推出,谢谢使用");
}
}
}
package xingYunChouJiang;
import java.util.Scanner;
public class ChouJiang {
int no;
int[] luckno = new int[5];
String chose;
void show() {
System.out.println("[奖客富翁系统]>抽奖");
System.out.println("请输入您的卡号");
Scanner input = new Scanner(System.in);
no = input.nextInt();
for (int i = 0; i < luckno.length; i++) {
luckno[i] = (int) (Math.random() * 8999 + 1000);
}
System.out.print("\n\n\n本日的幸运数字为:");
for (int i : luckno) {
System.out.print(i + "\t");
}
for (int i = 0; i < luckno.length; i++) {
if (no == luckno[i]) {
System.out.println("恭喜您,你是今日的幸运顾客");
} else if (i == luckno.length - 1) {
System.out.println("抱歉,您不是今日的幸运顾客");
}
}
System.out.println("继续吗?(y/n)");
chose = input.next();
if (chose.equals("y")) {
Logo choujiang = new Logo();
choujiang.show();
} else {
System.out.println("系统推出,谢谢使用");
}
}
}
package xingYunChouJiang;
class JiaMi {
int password[] = new int[6];
static int xinpassword = 0;
int jiami(int no) {
if (no >= 100000 && no <= 999999) {
for (int j = 0; j < password.length; j++) {
password[password.length - 1 - j] = no % 10;
no = no / 10;
//System.out.print(password[j]);
}
for (int j = 0; j < password.length; j++) {
password[j] = password[j] + 3;
password[j] = password[j] % 10;
//System.out.println(" ");
//System.out.print(password[j]);
}
for (int j = 0; j < password.length; j++) {
int t;
t = password[j];
password[j] = password[password.length - 1 - j];
password[password.length - 1 - j] = t;
//System.out.println(" ");
//System.out.print(password[j]);
}
for (int j = 0; j < password.length; j++) {
int a = 100000;
xinpassword = password[j] * a + xinpassword;
a = a / 10;
}
} else {
System.out.println("请输入6位数的值做密码");
}
return xinpassword;
}
}