Mainactivity类:

package com.example.XXSCYS;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView; public class MainActivity extends Activity {
public static final String FILENAME = "setting.set";
public static final String FILENAME1 = "mima.set";
public static final String FILENAME0 = "zancun.set";
private EditText et;
private EditText et1;
private EditText et2;
TextView text;
String c;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
String a;
String b;
Button button1;//定义按钮
TextView textView;
TextView textView1;
CheckBox CheckBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text=(TextView) findViewById(R.id.editText3);
b=readFiles0();
text.setText(b);
//登录
listener1 = new OnClickListener() {
public void onClick(View v) {
et=(EditText)findViewById(R.id.editText2);
et1=(EditText)findViewById(R.id.editText3);
c=readFiles1();
a=readFiles();
if(et.getText().toString().equals(c) && et1.getText().toString().equals(a)){
/*AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("密码输入正确!!" ) ;
builder.setPositiveButton("确定" , null );
*/
et.setText("");
Intent intent = new Intent(MainActivity.this, onectivity.class);
startActivity(intent);
//builder.show();
}
else{
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("密码错误!请重新输入!") ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText(""); } }
}; //注册
listener2 = new OnClickListener() {
public void onClick(View v) {
setTitle("注册");
Intent intent1 = new Intent(MainActivity.this, zhuce.class);
startActivity(intent1);
}
}; //忘记密码
listener3 = new OnClickListener() {
public void onClick(View v) {
a=readFiles();
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("请联系客服光大大设计者拿回密码!") ;
builder.setPositiveButton("确定" , null );
builder.show();
//et.setText("");
}
}; //记住我
listener4 = new OnClickListener() {
public void onClick(View v) {
et2=(EditText)findViewById(R.id.editText3);
writeFiles0(et2.getText().toString());
}
};
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.denglu);
button1.setOnClickListener(listener1); textView = (TextView) findViewById(R.id.zhuce);
textView.setOnClickListener(listener2); textView1 = (TextView) findViewById(R.id.wangji);
textView1.setOnClickListener(listener3); CheckBox = (CheckBox) findViewById(R.id.jizhu);
CheckBox.setOnClickListener(listener4); } // 保存文件暂时保存账号内容
private void writeFiles0(String content) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos0 = openFileOutput(FILENAME0,
Context.MODE_PRIVATE);
fos0.write(content.getBytes());
fos0.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取文件内容
private String readFiles0() {
String content = null ;
try {
FileInputStream fis = openFileInput(FILENAME0);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[];
int len = ;
while ((len = fis.read(buffer)) != -) {
baos.write(buffer, , len);
}
content = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content;
} // 读取文件内容
private String readFiles() {
String content = null ;
try {
FileInputStream fis = openFileInput(FILENAME);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[];
int len = ;
while ((len = fis.read(buffer)) != -) {
baos.write(buffer, , len);
}
content = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content;
} // 读取文件内容
private String readFiles1() {
String content1 = null ;
try {
FileInputStream fis = openFileInput(FILENAME1);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[];
int len = ;
while ((len = fis.read(buffer)) != -) {
baos.write(buffer, , len);
}
content1 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content1;
}
}

注册类:

package com.example.XXSCYS;  

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class zhuce extends Activity{ private EditText zhanghao;
private EditText mima;
private EditText QRmima;
private EditText nicheng;
private Button Btn;
private int dengji=0;
private int money=100;
private int daoju=0;
//private TextView contentView;
String xinxi;
public static final String FILENAME = "setting.set";
public static final String FILENAME1 = "mima.set";
public static final String FILENAME2 = "xinxi.set";
public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
OnClickListener listener1 = null;//监听器初始化
EditText editText;
@SuppressLint("CutPasteId") @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.zhuce);
zhanghao = (EditText) findViewById(R.id.editText1);
mima = (EditText) findViewById(R.id.editText2);
QRmima = (EditText) findViewById(R.id.editText3);
nicheng = (EditText) findViewById(R.id.editText4);
Btn = (Button) findViewById(R.id.button1); // contentView = (TextView) findViewById(R.id.contentview);
Btn.setOnClickListener(new OperateOnClickListener());
} class OperateOnClickListener implements OnClickListener {
@Override
public void onClick(View v) {
writeFiles(zhanghao.getText().toString());
writeFiles1(mima.getText().toString());
//writeFiles(QRmima.getText().toString());
writeFiles2(nicheng.getText().toString());
writeFiles3(""+dengji);
writeFiles4(""+money);
writeFiles5(""+daoju);
xinxi=readFiles2();
if(mima.getText().toString().equals(QRmima.getText().toString())){
AlertDialog.Builder builder = new Builder(zhuce.this);
builder.setTitle("注册成功" ) ;
builder.setMessage("昵称"+xinxi+"\n"+"等级"+dengji+"\n"+"金币"+money ) ;
builder.setPositiveButton("确定" , null );
builder.show();
zhanghao.setText("");
mima.setText("");
QRmima.setText("");
nicheng.setText("");
System.out.println(getFilesDir());
zhuce.this.finish();
}
else{
AlertDialog.Builder builder = new Builder(zhuce.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("密码确认不符!请重新输入!") ;
builder.setPositiveButton("确定" , null );
builder.show();
mima.setText("");
QRmima.setText("");
} }
} // 保存文件内容(账号)
private void writeFiles(String content) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos = openFileOutput(FILENAME,
Context.MODE_PRIVATE);
fos.write(content.getBytes());
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 保存文件内容 (密码)
private void writeFiles1(String content1) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos1 = openFileOutput(FILENAME1,
Context.MODE_PRIVATE);
fos1.write(content1.getBytes());
fos1.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 保存文件内容 (昵称)
private void writeFiles2(String content2) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos2 = openFileOutput(FILENAME2,
Context.MODE_PRIVATE);
fos2.write(content2.getBytes());
fos2.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 保存文件内容 (等级)
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 保存文件内容 (金币)
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取昵称
private String readFiles2() {
String content2 = null ;
try {
FileInputStream fis = openFileInput(FILENAME2);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content2 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content2;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
} }

登陆类(启动页面):

package com.example.XXSCYS;

import android.annotation.SuppressLint;
import android.app.TabActivity;
import android.content.Intent; import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.PopupMenu;
import android.widget.RadioGroup;
import android.widget.TabHost;
import android.widget.RadioGroup.OnCheckedChangeListener; public class onectivity extends TabActivity implements OnCheckedChangeListener{
private RadioGroup mainTab;
private TabHost tabhost;
private Intent a;
private Intent xinxi;
private Intent shangcheng;
@SuppressLint("NewApi") @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.onectivity);
final Button btn=(Button)findViewById(R.id.dati);
final PopupMenu popupMenu=new PopupMenu(this, btn);
popupMenu.inflate(R.menu.main); btn.setOnClickListener(new View.OnClickListener() { @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
popupMenu.show();
}
}); //菜单单击响应
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){
@Override
public boolean onMenuItemClick(MenuItem item){ switch(item.getItemId()){
case R.id.jiafa:
setTitle("加法");
Intent intent1 = new Intent(onectivity.this, jiafa.class);
startActivity(intent1);
break;
case R.id.jianfa:
setTitle("减法");
Intent intent2 = new Intent(onectivity.this, jianfa.class);
startActivity(intent2);
break;
case R.id.chengfa:
setTitle("乘法");
Intent intent3 = new Intent(onectivity.this, chengfa.class);
startActivity(intent3);
break;
case R.id.chufa:
setTitle("除法");
Intent intent4 = new Intent(onectivity.this, chufa.class);
startActivity(intent4);
break;
case R.id.hunhe:
setTitle("混合运算");
Intent intent5 = new Intent(onectivity.this, hunhe.class);
startActivity(intent5);
break;
}
return false;
}
}); mainTab=(RadioGroup)findViewById(R.id.main_tab);
mainTab.setOnCheckedChangeListener(this);
tabhost = getTabHost(); a= new Intent(this, a.class);
tabhost.addTab(tabhost.newTabSpec("a")
.setIndicator(getResources().getString(R.string.xinxi), getResources().getDrawable(R.drawable.xinxi))
.setContent(a)); xinxi= new Intent(this, xinxi.class);
tabhost.addTab(tabhost.newTabSpec("xinxi")
.setIndicator(getResources().getString(R.string.xinxi), getResources().getDrawable(R.drawable.xinxi))
.setContent(xinxi)); shangcheng = new Intent(this,shangcheng.class);
tabhost.addTab(tabhost.newTabSpec("shangcheng")
.setIndicator(getResources().getString(R.string.shangcheng), getResources().getDrawable(R.drawable.shangcheng))
.setContent(shangcheng)); } @Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch(checkedId){ case R.id.xinxi:
this.tabhost.setCurrentTabByTag("xinxi");
break;
case R.id.shangcheng:
this.tabhost.setCurrentTabByTag("shangcheng");
break;
case R.id.tuichu:
onectivity.this.finish();
break;
}
} }

加法类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class jiafa extends Activity { public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private float dengji;
private int daoju; private EditText et;
TextView text;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
Button button1;//定义按钮
Button button2;
Button button3;
Button button4;
double c;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;
setContentView(R.layout.jiafa); listener1 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+10;
int b=(int)(Math.random()*(-5))+20;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"+"+b+"=?");
c=a+b;
}
}; listener2 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles3();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
et=(EditText)findViewById(R.id.editText2);
if(Integer.parseInt(et.getText().toString())==c){
AlertDialog.Builder builder = new Builder(jiafa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜啦,回答正确!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i+10;
dengji=(float) (j+0.1);
}
else{
AlertDialog.Builder builder = new Builder(jiafa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("很遗憾,回答错误!加油哦!正确答案为:"+c ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i-5;
}
writeFiles4(""+money);
writeFiles3(""+dengji);
}
}; listener3 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+10;
int b=(int)(Math.random()*(-5))+20;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"+"+b+"=?");
c=a+b;
}
}; listener4 = new OnClickListener() {
public void onClick(View v) {
String o;
o=readFiles5();
final int p = Integer.parseInt(o);
if(o.equals("0")) {
AlertDialog.Builder builder = new Builder(jiafa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("您的道具余额不足,请去商城购买道具!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
AlertDialog.Builder builder = new Builder(jiafa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("正确答案为:"+c+"\n"+"您用掉了一个道具" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
daoju=p-1;
writeFiles5(""+daoju);
}
}
};
setContentView(R.layout.jiafa);
button1 = (Button) findViewById(R.id.start);
button1.setOnClickListener(listener1); button2 = (Button) findViewById(R.id.tijiao);
button2.setOnClickListener(listener2); button3 = (Button) findViewById(R.id.next);
button3.setOnClickListener(listener3); button4 = (Button) findViewById(R.id.daoju);
button4.setOnClickListener(listener4); } // 读取等级
private String readFiles3() {
String content3 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content3 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content3;
}
// 保存文件内容
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

减法类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class jianfa extends Activity { public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private float dengji;
private int daoju; private EditText et;
TextView text;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
Button button1;//定义按钮
Button button2;
Button button3;
Button button4;
double c;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;
setContentView(R.layout.jiafa); listener1 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+20;
int b=(int)(Math.random()*(-5))+10;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"-"+b+"=?");
c=a-b;
}
}; listener2 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles3();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
et=(EditText)findViewById(R.id.editText2);
if(Integer.parseInt(et.getText().toString())==c){
AlertDialog.Builder builder = new Builder(jianfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜啦,回答正确!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i+10;
dengji=(float) (j+0.1);
}
else{
AlertDialog.Builder builder = new Builder(jianfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("很遗憾,回答错误!加油哦!正确答案为:"+c ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i-5;
}
writeFiles4(""+money);
writeFiles3(""+dengji);
}
}; listener3 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+20;
int b=(int)(Math.random()*(-5))+10;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"-"+b+"=?");
c=a-b;
}
}; listener4 = new OnClickListener() {
public void onClick(View v) {
String o;
o=readFiles5();
final int p = Integer.parseInt(o);
if(o.equals("0")) {
AlertDialog.Builder builder = new Builder(jianfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("您的道具余额不足,请去商城购买道具!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
AlertDialog.Builder builder = new Builder(jianfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("正确答案为:"+c+"\n"+"您用掉了一个道具" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
daoju=p-1;
writeFiles5(""+daoju);
}
}
};
setContentView(R.layout.jiafa);
button1 = (Button) findViewById(R.id.start);
button1.setOnClickListener(listener1); button2 = (Button) findViewById(R.id.tijiao);
button2.setOnClickListener(listener2); button3 = (Button) findViewById(R.id.next);
button3.setOnClickListener(listener3); button4 = (Button) findViewById(R.id.daoju);
button4.setOnClickListener(listener4); } // 读取等级
private String readFiles3() {
String content3 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content3 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content3;
}
// 保存文件内容
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

乘法类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class chengfa extends Activity { public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private float dengji;
private int daoju; private EditText et;
TextView text;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
Button button1;//定义按钮
Button button2;
Button button3;
Button button4;
double c;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;
setContentView(R.layout.jiafa); listener1 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+10;
int b=(int)(Math.random()*(-5))+20;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"*"+b+"=?");
c=a*b;
}
}; listener2 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles3();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
et=(EditText)findViewById(R.id.editText2);
if(Integer.parseInt(et.getText().toString())==c){
AlertDialog.Builder builder = new Builder(chengfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜啦,回答正确!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i+10;
dengji=(float) (j+0.1);
}
else{
AlertDialog.Builder builder = new Builder(chengfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("很遗憾,回答错误!加油哦!正确答案为:"+c ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i-5;
}
writeFiles4(""+money);
writeFiles3(""+dengji);
}
}; listener3 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+10;
int b=(int)(Math.random()*(-5))+20;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"*"+b+"=?");
c=a*b;
}
}; listener4 = new OnClickListener() {
public void onClick(View v) {
String o;
o=readFiles5();
final int p = Integer.parseInt(o);
if(o.equals("0")) {
AlertDialog.Builder builder = new Builder(chengfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("您的道具余额不足,请去商城购买道具!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
AlertDialog.Builder builder = new Builder(chengfa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("正确答案为:"+c+"\n"+"您用掉了一个道具" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
daoju=p-1;
writeFiles5(""+daoju);
}
}
};
setContentView(R.layout.jiafa);
button1 = (Button) findViewById(R.id.start);
button1.setOnClickListener(listener1); button2 = (Button) findViewById(R.id.tijiao);
button2.setOnClickListener(listener2); button3 = (Button) findViewById(R.id.next);
button3.setOnClickListener(listener3); button4 = (Button) findViewById(R.id.daoju);
button4.setOnClickListener(listener4); } // 读取等级
private String readFiles3() {
String content3 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content3 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content3;
}
// 保存文件内容
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

除法类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class chufa extends Activity { public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private float dengji;
private int daoju; private EditText et;
TextView text;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
Button button1;//定义按钮
Button button2;
Button button3;
Button button4;
double c;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;
setContentView(R.layout.jiafa); listener1 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+20;
int b=(int)(Math.random()*(-5))+10;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"/"+b+"=?");
c=a/b;
}
}; listener2 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles3();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
et=(EditText)findViewById(R.id.editText2);
if(Integer.parseInt(et.getText().toString())==c){
AlertDialog.Builder builder = new Builder(chufa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜啦,回答正确!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i+10;
dengji=(float) (j+0.1);
}
else{
AlertDialog.Builder builder = new Builder(chufa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("很遗憾,回答错误!加油哦!正确答案为:"+c ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i-5;
}
writeFiles4(""+money);
writeFiles3(""+dengji);
}
}; listener3 = new OnClickListener() {
public void onClick(View v) {
int a=(int)(Math.random()*(-5))+20;
int b=(int)(Math.random()*(-5))+10;
text=(TextView) findViewById(R.id.editText3);
text.setText(a+"/"+b+"=?");
c=a/b;
}
}; listener4 = new OnClickListener() {
public void onClick(View v) {
String o;
o=readFiles5();
final int p = Integer.parseInt(o);
if(o.equals("0")) {
AlertDialog.Builder builder = new Builder(chufa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("您的道具余额不足,请去商城购买道具!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
AlertDialog.Builder builder = new Builder(chufa.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("正确答案为:"+c+"\n"+"您用掉了一个道具" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
daoju=p-1;
writeFiles5(""+daoju);
}
}
};
setContentView(R.layout.jiafa);
button1 = (Button) findViewById(R.id.start);
button1.setOnClickListener(listener1); button2 = (Button) findViewById(R.id.tijiao);
button2.setOnClickListener(listener2); button3 = (Button) findViewById(R.id.next);
button3.setOnClickListener(listener3); button4 = (Button) findViewById(R.id.daoju);
button4.setOnClickListener(listener4); } // 读取等级
private String readFiles3() {
String content3 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content3 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content3;
}
// 保存文件内容
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

混合运算类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView; public class hunhe extends Activity { public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private float dengji;
private int daoju; int a,x,y,o,p,j1,j2;
float z,q,s1,s2,f,n;
private EditText et;
TextView text;
OnClickListener listener1 = null;//监听器初始化
OnClickListener listener2 = null;
OnClickListener listener3 = null;
OnClickListener listener4 = null;
Button button1;//定义按钮
Button button2;
Button button3;
Button button4;
//double c;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);;
setContentView(R.layout.jiafa); listener1 = new OnClickListener() {
public void onClick(View v) {
text=(TextView) findViewById(R.id.editText3);
x=(int)(1+Math.random()*100);
y=(int)(1+Math.random()*100); o=(int)(1+Math.random()*100);
p=(int)(1+Math.random()*100); a=(int)(1+Math.random()*16); j1=x*y;
j2=o*p;
s1=x/y;
s2=o/p;
switch (a) {
case 1:
text.setText("("+x+"+"+y+")"+"*"+"("+o+"+"+p+")"+"=");
z=x+y;
q=o+p;
f=z*q;
break;
case 2:
z=x-y;
if(z<0)
{text.setText("("+y+"-"+x+")"+"*"+"("+o+"+"+p+")"+"=");
z=-z;
}
else {
text.setText("("+x+"-"+y+")"+"*"+"("+o+"+"+p+")"+"="); }
q=o+p;
f=z*q; break;
case 3:
z=x-y;
if(z>0)
text.setText("("+x+"-"+y+")"+"/"+"("+o+"+"+p+")"+"=");
else {
text.setText("("+y+"-"+x+")"+"/"+"("+o+"+"+p+")"+"=");
z=-z;
}
q=o+p;
f=q*z; break;
case 4:
text.setText("("+x+"+"+y+")"+"/"+"("+o+"+"+p+")"+"=");
f=(x+y)/(o+p); break;
case 5:
if(o==p)
o++;
z=x-y;
q=o-p; if(z>0 && q>0)
text.setText("("+x+"-"+y+")"+"/"+"("+o+"-"+p+")"+"=");
if(z>0 && q<0)
{ text.setText("("+x+"-"+y+")"+"/"+"("+p+"-"+o+")"+"=");
q=-q;
}
if(z<0 && q>0)
{text.setText("("+y+"-"+x+")"+"/"+"("+o+"-"+p+")"+"=");
z=-z;
}
if(z<0 && q<0)
{ text.setText("("+y+"-"+x+")"+"/"+"("+p+"-"+o+")"+"=");
z=-z;
q=-q;
}
f=z/q; break;
case 6:
q=o-p;
z=x+y;
if(q>0)
text.setText("("+x+"+"+y+")"+"/"+"("+o+"-"+p+")"+"=");
else
{text.setText("("+x+"+"+y+")"+"/"+"("+p+"-"+o+")"+"=");
q=-q;
}
f=z/q; break;
case 7:
z=x-y;
q=o+p;
if(z>0)
text.setText("("+x+"-"+y+")"+"*"+"("+o+"+"+p+")"+"=");
else
{
text.setText("("+y+"-"+x+")"+"*"+"("+o+"+"+p+")"+"=");
z=-z;
}
f=z*q; break;
case 8:
q=o-p;
z=x+y;
if(q>0)
text.setText("("+x+"+"+y+")"+"*"+"("+o+"-"+p+")"+"=");
else
{
text.setText("("+x+"+"+y+")"+"*"+"("+o+"-"+p+")"+"=");
q=-q;
}
f=z*q; break; case 9:
if(j1>j2)
{text.setText(x+"*"+y+"-"+o+"*"+p+"=");
f=j1-j2;
}
else
{
text.setText(o+"*"+p+"-"+x+"*"+y+"=");
f=j2-j1;
} break;
case 10:
if(j1>s2)
{
text.setText(x+"*"+y+"-"+o+"/"+p+"=");
f=j1-s2;
}
else
{
text.setText(o+"/"+p+"-"+x+"*"+y+"=");
f=s2-j1;
} break;
case 11:
if(s1>j2)
{
text.setText(x+"/"+y+"-"+o+"*"+p+"=");
f=s1-j2;
}
else
{
text.setText(o+"*"+p+"-"+x+"/"+y+"=");
f=j2-s1;
} break;
case 12:
f=s1-s2;
if(f>0)
{
text.setText(x+"/"+y+"-"+o+"/"+p+"="); }
if(f<0)
{
text.setText(o+"/"+p+"-"+x+"/"+y+"=");
f=s2-s1;
} break;
case 13:
text.setText(x+"*"+y+"+"+o+"*"+p+"=");
f=j1+j2; break;
case 14:
text.setText(x+"*"+y+"+"+o+"/"+p+"=");
f=1+s2; break;
case 15:
text.setText(x+"/"+y+"+"+o+"*"+p+"=");
f=s1+j2; break;
case 16:
text.setText(x+"/"+y+"+"+o+"/"+p+"=");
f=s2+s1; break;
default:
break;
} }
}; listener2 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles3();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
et=(EditText)findViewById(R.id.editText2);
if(Integer.parseInt(et.getText().toString())==f){
AlertDialog.Builder builder = new Builder(hunhe.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜啦,回答正确!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i+10;
dengji=(float) (j+0.1);
}
else{
AlertDialog.Builder builder = new Builder(hunhe.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("很遗憾,回答错误!加油哦!正确答案为:"+f ) ;
builder.setPositiveButton("确定" , null );
builder.show();
et.setText("");
text.setText("");
money=i-5;
}
writeFiles4(""+money);
writeFiles3(""+dengji);
}
}; listener3 = new OnClickListener() {
public void onClick(View v) {
text=(TextView) findViewById(R.id.editText3);
x=(int)(1+Math.random()*100);
y=(int)(1+Math.random()*100); o=(int)(1+Math.random()*100);
p=(int)(1+Math.random()*100); a=(int)(1+Math.random()*16); j1=x*y;
j2=o*p;
s1=x/y;
s2=o/p;
switch (a) {
case 1:
text.setText("("+x+"+"+y+")"+"*"+"("+o+"+"+p+")"+"=");
z=x+y;
q=o+p;
f=z*q;
break;
case 2:
z=x-y;
if(z<0)
{text.setText("("+y+"-"+x+")"+"*"+"("+o+"+"+p+")"+"=");
z=-z;
}
else {
text.setText("("+x+"-"+y+")"+"*"+"("+o+"+"+p+")"+"="); }
q=o+p;
f=z*q; break;
case 3:
z=x-y;
if(z>0)
text.setText("("+x+"-"+y+")"+"/"+"("+o+"+"+p+")"+"=");
else {
text.setText("("+y+"-"+x+")"+"/"+"("+o+"+"+p+")"+"=");
z=-z;
}
q=o+p;
f=q*z; break;
case 4:
text.setText("("+x+"+"+y+")"+"/"+"("+o+"+"+p+")"+"=");
f=(x+y)/(o+p); break;
case 5:
if(o==p)
o++;
z=x-y;
q=o-p; if(z>0 && q>0)
text.setText("("+x+"-"+y+")"+"/"+"("+o+"-"+p+")"+"=");
if(z>0 && q<0)
{ text.setText("("+x+"-"+y+")"+"/"+"("+p+"-"+o+")"+"=");
q=-q;
}
if(z<0 && q>0)
{text.setText("("+y+"-"+x+")"+"/"+"("+o+"-"+p+")"+"=");
z=-z;
}
if(z<0 && q<0)
{ text.setText("("+y+"-"+x+")"+"/"+"("+p+"-"+o+")"+"=");
z=-z;
q=-q;
}
f=z/q; break;
case 6:
q=o-p;
z=x+y;
if(q>0)
text.setText("("+x+"+"+y+")"+"/"+"("+o+"-"+p+")"+"=");
else
{text.setText("("+x+"+"+y+")"+"/"+"("+p+"-"+o+")"+"=");
q=-q;
}
f=z/q; break;
case 7:
z=x-y;
q=o+p;
if(z>0)
text.setText("("+x+"-"+y+")"+"*"+"("+o+"+"+p+")"+"=");
else
{
text.setText("("+y+"-"+x+")"+"*"+"("+o+"+"+p+")"+"=");
z=-z;
}
f=z*q; break;
case 8:
q=o-p;
z=x+y;
if(q>0)
text.setText("("+x+"+"+y+")"+"*"+"("+o+"-"+p+")"+"=");
else
{
text.setText("("+x+"+"+y+")"+"*"+"("+o+"-"+p+")"+"=");
q=-q;
}
f=z*q; break; case 9:
if(j1>j2)
{text.setText(x+"*"+y+"-"+o+"*"+p+"=");
f=j1-j2;
}
else
{
text.setText(o+"*"+p+"-"+x+"*"+y+"=");
f=j2-j1;
} break;
case 10:
if(j1>s2)
{
text.setText(x+"*"+y+"-"+o+"/"+p+"=");
f=j1-s2;
}
else
{
text.setText(o+"/"+p+"-"+x+"*"+y+"=");
f=s2-j1;
} break;
case 11:
if(s1>j2)
{
text.setText(x+"/"+y+"-"+o+"*"+p+"=");
f=s1-j2;
}
else
{
text.setText(o+"*"+p+"-"+x+"/"+y+"=");
f=j2-s1;
} break;
case 12:
f=s1-s2;
if(f>0)
{
text.setText(x+"/"+y+"-"+o+"/"+p+"="); }
if(f<0)
{
text.setText(o+"/"+p+"-"+x+"/"+y+"=");
f=s2-s1;
} break;
case 13:
text.setText(x+"*"+y+"+"+o+"*"+p+"=");
f=j1+j2; break;
case 14:
text.setText(x+"*"+y+"+"+o+"/"+p+"=");
f=1+s2; break;
case 15:
text.setText(x+"/"+y+"+"+o+"*"+p+"=");
f=s1+j2; break;
case 16:
text.setText(x+"/"+y+"+"+o+"/"+p+"=");
f=s2+s1; break;
default:
break;
}
}
}; listener4 = new OnClickListener() {
public void onClick(View v) {
String o;
o=readFiles5();
final int p = Integer.parseInt(o);
if(o.equals("0")) {
AlertDialog.Builder builder = new Builder(hunhe.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("您的道具余额不足,请去商城购买道具!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
AlertDialog.Builder builder = new Builder(hunhe.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("正确答案为:"+f+"\n"+"您用掉了一个道具" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
daoju=p-1;
writeFiles5(""+daoju);
}
}
};
setContentView(R.layout.jiafa);
button1 = (Button) findViewById(R.id.start);
button1.setOnClickListener(listener1); button2 = (Button) findViewById(R.id.tijiao);
button2.setOnClickListener(listener2); button3 = (Button) findViewById(R.id.next);
button3.setOnClickListener(listener3); button4 = (Button) findViewById(R.id.daoju);
button4.setOnClickListener(listener4); } // 读取等级
private String readFiles3() {
String content3 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content3 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content3;
}
// 保存文件内容
private void writeFiles3(String content3) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos3 = openFileOutput(FILENAME3,
Context.MODE_PRIVATE);
fos3.write(content3.getBytes());
fos3.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

商城类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream; import android.R.integer;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView; public class shangcheng extends Activity{
OnClickListener listener1 = null;
Button button1;//定义按钮
public static final String FILENAME4 = "money.set";
public static final String FILENAME5 = "daoju.set";
private int money;
private int daoju; /** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.shangcheng); listener1 = new OnClickListener() {
public void onClick(View v) {
String m;
String n;
m=readFiles4();
n=readFiles5();
final int i = Integer.parseInt(m);
final float j = Float.parseFloat(n);
if(i<=0){
AlertDialog.Builder builder = new Builder(shangcheng.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("对不起,您的金币不足!!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
else{
money=i-50;
daoju=(int) (j+1);
writeFiles4(""+money);
writeFiles5(""+daoju);
AlertDialog.Builder builder = new Builder(shangcheng.this);
builder.setTitle("信息提醒" ) ;
builder.setMessage("恭喜您,道具购买成功!" ) ;
builder.setPositiveButton("确定" , null );
builder.show();
}
}
}; setContentView(R.layout.shangcheng);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(listener1); }
// 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 保存文件内容
private void writeFiles4(String content4) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos4 = openFileOutput(FILENAME4,
Context.MODE_PRIVATE);
fos4.write(content4.getBytes());
fos4.close();
} catch (Exception e) {
e.printStackTrace();
}
} // 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
// 保存文件内容
private void writeFiles5(String content5) {
try {
// 打开文件获取输出流,文件不存在则自动创建
FileOutputStream fos5 = openFileOutput(FILENAME5,
Context.MODE_PRIVATE);
fos5.write(content5.getBytes());
fos5.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

用户信息类:

package com.example.XXSCYS;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream; import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView; public class xinxi extends Activity{
TextView textView;
public static final String FILENAME3 = "dengji.set";
public static final String FILENAME4 = "money.set";
public static final String FILENAME2 = "xinxi.set";
public static final String FILENAME5 = "daoju.set";
private String money;
private String dengji;
private String nicheng;
private String daoju; protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.xinxi);
nicheng=readFiles2();
money=readFiles4();
dengji=readFiles3();
daoju=readFiles5();
textView = (TextView) findViewById(R.id.textView1);
textView.setText("昵称:"+nicheng+"\n"+"等级:"+dengji+"\n"+"金币:"+money+"\n"+"道具:"
+daoju+"\n\n"+"温馨提示:"+"\n"+"每答对一道题可获取10金币,等级提升0.1级,答错一题则扣5金币"); } // 读取昵称
private String readFiles2() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME2);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
} // 读取等级
private String readFiles3() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME3);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
} // 读取金币
private String readFiles4() {
String content4 = null ;
try {
FileInputStream fis = openFileInput(FILENAME4);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content4 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content4;
}
// 读取道具数
private String readFiles5() {
String content5 = null ;
try {
FileInputStream fis = openFileInput(FILENAME5);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = fis.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
content5 = baos.toString();
fis.close();
baos.close();
} catch (Exception e) {
e.printStackTrace();
}
return content5;
}
}

附加类:

package com.example.XXSCYS;
import android.app.Activity;
import android.os.Bundle; public class a extends Activity{
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.a);
}
}

项目发布:

我们团队把整个项目文件上传到Github,链接地址:https://github.com/scarletcirno/students

app推广:

第一步:在QQ群和微信群里边,呼吁大家下载APP体验,但是效果比较差,下载量比较小,于是采用逐个逐个单独和同学沟通,认真听取他们的体验感受。

第二步:我们采用了人海战术,通过微信公众号来推广,找到一些微信公众号平台,比如:广商微生活。在底部菜单加上我们APP的下载链接,引导他们下载使用。

第三步:最后采用有针对性的推广,锁定用户人群,小学生的家长,于是找到各个同学的亲戚朋友,让他们下载APP体验,总结不足和优点。

总结:这推广过程中,我们也遇到了很多困难,但是,我们收获了很多,明白产品推广的不易之处,相信这份体验会给将来的学习和工作带来一点帮助。

小学生四则运算APP核心代码公布的更多相关文章

  1. 《软件工程》小组团队项目-小学生四则运算APP(First Sprint)

    <软件工程>团队项目我们小组选择了小学生四则运算APP,在上学期原有的项目基础上进行更新升级.(自我感觉我们团队上学期的小学生四则运算APP是较为成功且实用的,不过这学期学习到了新的知识, ...

  2. 数学战神app(小学生四则运算app)开发需求及进度

    项目名字:“数学战神” 开发环境:Android eclipse 团队名称:战神联盟 团队成员:陈思明,许家豪,王宏财,吴旭涛 在之前的四则运算APP中添加更多的实用功能,并在各种平台推广宣传. 预加 ...

  3. 数学口袋精灵app(小学生四则运算app)开发需求

    数学口袋精灵APP,摒除了传统乏味无趣学习数学四则运算的模式,采用游戏的形式,让小朋友在游戏中学习,培养了小朋友对数学的兴趣,让小朋友在游戏中运算能力得到充分提升.快乐学习,成长没烦恼! 项目名字:“ ...

  4. 小学生四则运算App实验成果

    组名:会飞的小鸟 组员:徐侃 陈志棚  罗伟业 刘芮熔 —成员分工: —①刘芮熔:设置安卓包.界面的代码,界面的排序. —②陈志棚:加减乘除的判断异常处理,例如除数不能为零的异常处理等问题. —③徐侃 ...

  5. 数学战神app(小学生四则运算app)进度

    背景音乐仍有瑕疵,还在完善,不过大概完成,完善按钮声音,提示音等. 许家豪:负责代码程序设计 陈思明:界面背景美化 吴旭涛.王宏财:查缺补漏

  6. 四则运算app第一阶段冲刺

    第一阶段冲刺 [开发环境]:eclipse [开发项目]:小学生四则运算APP [开发人员]:郑胜斌 http://www.cnblogs.com/zsb1/ 孔德颖 http://www.cnblo ...

  7. 四则运算APP最后阶段

    四则运算APP最后阶段 [开发环境]:eclipse [开发项目]:小学生四则运算APP [开发人员]:郑胜斌 http://www.cnblogs.com/zsb1/ 孔德颖 http://www. ...

  8. 作业6小学生四则运算测试APP的NABCD模型

    小学生四则运算测试NABCD模型 组员:李新,朱浩龙,叶煜稳,陈俊金,林德麟 (1)  N (Need 需求) 需求分析: 四则运算是小学生学习数学的核心和基础,必须经过大量的练习才能熟练掌握,但是一 ...

  9. APP反编译第一课《如何找到核心代码》

    相信很多人都应该会去接触APP反编译,本小七给大家带来入门级别套路,自己也在慢慢摸索学习,一起成长吧.第一步,反编译需要的工具有:一.java环境,其实这里你只要安装了burp就不用管这个的二.apk ...

随机推荐

  1. 配置私有SSH

    1.cd ~/.ssh进入ssh文件夹. 2.ls,查看文件夹里面的内容 3.ssh-keygen -t rsa -C "zhanggui@marchsoft.cn” 一路回车 4.cd ~ ...

  2. 【18】如何把数据存储到MongoDB数据库

    如何把数据存储到MongoDB数据库 时间:2018.10.31                   edit by :北鼻 一.mongoDB环境安装 需要使用mongoDB数据库的话需要安装环境, ...

  3. MySQL InnoDB Update和Crash Recovery流程

    MySQL InnoDB Update和Crash Recovery流程 概要信息 首先介绍了Redo,Undo,Log Sequence Number (LSN),Checkpoint,Rollba ...

  4. GC Ergonomics间接引发的锁等待超时问题排查分析

    1. 问题背景 上周线上某模块出现锁等待超时,如下图所示: 我虽然不是该模块负责人,但出于好奇,也一起帮忙排查定位问题. 这里的业务背景就是在执行到某个地方时,需要去表中插入一批数据,这批数据需要根据 ...

  5. Node.js webpack Vue-CLI --安装

    Node.js 安装 从官网 下载 安装 Node.js 官网 Node.js 官方文档 cmd 命令 node -v 查看版本号 v10.15.0 npm 包管理工具 npm 是JavaScript ...

  6. 【洛谷】【动态规划/01背包】P2925 [USACO08DEC]干草出售Hay For Sale

    [题目描述:] 约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包干草,每一包都有它 ...

  7. 【转】Android,iOS打开手机QQ与指定用户聊天界面

    在浏览器中可以通过JS代码打开QQ并弹出聊天界面,一般作为客服QQ使用.而在移动端腾讯貌似没有公布提供类似API,但是却可以使用schema模式来启动手机QQ. 以下为具体代码: Android: S ...

  8. ORB-SLAM2(3) ROS下实时跑ORB_SLAM2

    Step1 : 运行内核 roscore Step2 : 启动相机 cd catkin_ws/src/usb_cam/launch #进入usb_cam驱动的安装目录 roslaunch my_cam ...

  9. e 的由来

    https://www.zhihu.com/question/20296247 对数的发现 很多科学家发现对数螺线在自然界中广泛存在.从大如星系.台风,到小如花朵.海螺……宇宙中到处都是对数螺线的身影

  10. Shell逻辑语句

    case esac 语句 参考 :https://blog.csdn.net/wu20093346/article/details/47210809 case ... esac 与其他语言中的 swi ...