首页 技术 正文
技术 2022年11月17日
0 收藏 311 点赞 3,340 浏览 2586 个字
package java第二周学习;
import javax.swing.JOptionPane;
public class 数学题 {private int a;
private int b;
private int d;
private String c;
private boolean e;
数学题(int a, int b, String c) {
this.a = a;
this.b = b;
this.c = c;
}
public void xianshi (int i)
{
String s;
s= JOptionPane.showInputDialog(a+c+b+"=" );
d = Integer.parseInt(s);
}
public void pan() {
switch (c) {
case "+":
if(a+b==d)
{
e=true;
}
else
{
e=false;
}
break;
case "-":
if(a-b==d)
{
e=true;
}
else
{
e=false;
}
break;
case "*":
if(a*b==d)
{
e=true;
}
else
{
e=false;
}
break;
default:
if(a/b==d)
{
e=true;
}
else
{
e=false;
}
break;
}
}
public boolean isE() {
return e;
}
public void setE(boolean e) {
this.e = e;
}
public int getA() {
return a;
}
public void setA(int a) {
this.a = a;
}
public int getB() {
return b;
}
public void setB(int b) {
this.b = b;
}
public int getD() {
return d;
}
public void setD(int d) {
this.d = d;
}
public String getC() {
return c;
}
public void setC(String c) {
this.c = c;
}}

  

package java第二周学习;import java.util.LinkedList;
import java.util.Scanner;
import javax.swing.JOptionPane;public class 小学四年学习 {@SuppressWarnings({ "unlikely-arg-type", "resource", "unused" })
public static void main(String[] args) {
LinkedList<数学题> shu = new LinkedList<数学题>();
int i = 0;
String f;
//生成数学题数据
while (i < 30) {
int a = (int) (Math.random() * 100);
int b = (int) (Math.random() * 100);
int c = (int) (Math.random() * 4);
switch (c) {
case 1:
f = "+";
break;case 2:
f = "-";
break;
case 3:
f = "*";
break;
default:
f = "/";
break;
}
数学题 add = new 数学题(a, b, f);
shu.add(add);
i++;
}
denglu(shu);}// 计算得分和哪道题错误
public static void defen(LinkedList<数学题> a) {
int j = 0;
int m = 0;
for (int i = 0; i < a.size(); i++) {
if (a.get(i).isE()) {
j++;} else {
m++;
}}
JOptionPane.showMessageDialog(null, "总分是 " + (j * 10), "您的水平", JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "错误了" +m+"道","您的水平", JOptionPane.PLAIN_MESSAGE);
for (int i = 0; i < a.size(); i++) {
if (!(a.get(i).isE())) {JOptionPane.showMessageDialog(null, (i+1)+"错误了","您的水平", JOptionPane.PLAIN_MESSAGE);
}
}
}// 开始
public static void open(LinkedList<数学题> a) {
for (int i = 0; i < a.size(); i++) {
a.get(i).xianshi(i);
a.get(i).pan();
JOptionPane.showMessageDialog(null, "您的答案是 " + a.get(i).isE(), "你的水平", JOptionPane.PLAIN_MESSAGE);
}
defen(a);}
//账号登录界面
public static void denglu(LinkedList<数学题> a)
{
String Zhanghao, Mima, W;
JOptionPane.showConfirmDialog(null, "小学四年级数学题", "数学是个好东西!", JOptionPane.YES_NO_CANCEL_OPTION);
Zhanghao = JOptionPane.showInputDialog("输入账号:");
if (Zhanghao.equals("555")) {
Mima = JOptionPane.showInputDialog("输入密码:");
if (Mima.equals("555")) {
int yanzhengma = (int) (Math.random() * 10000);
W = JOptionPane.showInputDialog("输入验证码:"+yanzhengma);
String s=Integer.toString(yanzhengma);
if(W.equals(s))
{
JOptionPane.showMessageDialog(null, "登录成功!");
open(a);
}
else {
JOptionPane.showMessageDialog(null, "验证码错误");
}}else {
JOptionPane.showMessageDialog(null, "密码错误");
}
}
else {
JOptionPane.showMessageDialog(null, "无此账号记录");
}
}
}

  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,077
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,552
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,401
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,176
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,813
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,896