Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2 #24 第二次实验 #198

Merged
merged 1 commit into from
Apr 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

/**
* Created by zzh on 2017/4/14.
*/
public class BoardPrecenter {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

/**
* Created by zzh on 2017/4/15.
*/
public class ChessBoard extends View {
protected float boardSX;
protected float boardSY;
protected float boardEX;
protected float boardEY;
protected float grapX;
protected float grapY;
protected int countX;
protected int countY;
public ChessBoard(Context context, AttributeSet attrs){
super(context,attrs);
boardSX=20;boardSY=260;
boardEX=420;boardEY=660;
countX=10;countY=10;
grapX=(boardEX-boardSX)/countX;
grapY=(boardEY-boardSY)/countY;
}

@Override
protected void onDraw(Canvas canvas){
super.onDraw(canvas);
Paint paint=new Paint();
paint.setColor(Color.rgb(150,200,0));
paint.setShadowLayer(2,3,3,Color.BLACK);
Rect RectBoard=new Rect(0,0,448,687);
canvas.drawRect(RectBoard,paint);
paint.setColor(Color.BLACK);
for(int i=0;i<=countX;i++){
canvas.drawLine(boardSX+grapX*i,boardSY,boardSX+grapX*i,boardEY,paint);
}
for(int j=0;j<=countY;j++){
canvas.drawLine(boardSX,boardSY+grapY*j,boardEX,boardSY+grapY*j,paint);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

/**
* Created by zzh on 2017/4/14.
*/
public class LoginService {
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Net1414080903218Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1414080903218);
Button ButtonPtoC=(Button) findViewById(R.id.PtoCButton);
if (ButtonPtoC != null) {
ButtonPtoC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent IntentStartBoard=new Intent(v.getContext(),Net1414080903218BoardActivity.class);
startActivity(IntentStartBoard);
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class Net1414080903218BoardActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_net1414080903218_board);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package edu.hzuapps.androidlabs.homeworks.net1414080903218;

/**
* Created by zzh on 2017/4/14.
*/
public class Player {
protected int countPieces;
protected boolean isWin;
protected boolean isFirst;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions AndroidLabs/app/src/main/res/layout/activity_net1414080903218.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/net1414080903218_bg"
tools:context="edu.hzuapps.androidlabs.homeworks.net1414080903218.Net1414080903218Activity">

<TextView
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
android:text="人机对战"
android:id="@+id/PtoCButton"
android:layout_marginTop="72dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="双人对战"
android:id="@+id/PtoPButton"
android:layout_marginTop="172dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="edu.hzuapps.androidlabs.homeworks.net1414080903218.Net1414080903218BoardActivity">

<edu.hzuapps.androidlabs.homeworks.net1414080903218.ChessBoard
android:id="@+id/ChessBosrd"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</RelativeLayout>
2 changes: 1 addition & 1 deletion AndroidLabs/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<resources>
<string name="app_name">Android开发</string>
<string name="action_settings">设置</string>

Expand Down