forked from hzuapps/android-labs-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown
committed
May 20, 2018
1 parent
3c20ff2
commit 245005a
Showing
7 changed files
with
189 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 58 additions & 2 deletions
60
...204/app/src/main/java/com/example/gwl20/soft1614080902204/soft1614080902204CActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,75 @@ | ||
package com.example.gwl20.soft1614080902204; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.design.widget.FloatingActionButton; | ||
import android.support.design.widget.Snackbar; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.support.v7.widget.Toolbar; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
|
||
public class soft1614080902204CActivity extends AppCompatActivity { | ||
|
||
private Button fanhui; | ||
private TextView jieguo,xx; | ||
String ret; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_soft1614080902204_c); | ||
|
||
fanhui=(Button) findViewById(R.id.button_fanhui); | ||
jieguo=(TextView)findViewById(R.id.textview_03_01); | ||
xx=(TextView)findViewById(R.id.textview_03_02); | ||
final Intent intent=getIntent(); | ||
String st=intent.getStringExtra("quan"); | ||
int s=Integer.parseInt(st); | ||
String sp=null; | ||
if(s==2){ | ||
sp="布 "; | ||
} | ||
else if(s==1){ | ||
sp="石头"; | ||
} | ||
else if(s==0){ | ||
sp="剪刀"; | ||
} | ||
int x=(int)(Math.random()*3); | ||
String sx=null; | ||
if(x==2){ | ||
sx="布 "; | ||
} | ||
else if(x==1){ | ||
sx="石头"; | ||
} | ||
else if(x==0){ | ||
sx="剪刀"; | ||
} | ||
if ((s == 0 && x == 1) || | ||
(s == 1 && x == 2) || | ||
(s == 2 && x == 0)){ | ||
jieguo.setText("^-^ 你输了 真瓜怂"); | ||
ret="输了"; | ||
} | ||
else if (s == x) { | ||
jieguo.setText("有缘TnT平手,再来"); | ||
ret="平手"; | ||
} | ||
else { | ||
jieguo.setText("(^v^) oh 你赢了 "); | ||
ret="赢了"; | ||
} | ||
xx.setText("你出"+sp+",电脑出"+sx); | ||
ret=xx.getText().toString()+" 因此 "+ret; | ||
fanhui.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent data=new Intent(); | ||
data.putExtra("jieguo",ret); | ||
setResult(2,data); | ||
finish(); | ||
} | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.