2008年8月24日
摘要:
1import java.util.Scanner;
2
3public class StuManager {
4
5 /** *//**
6 *&...
阅读全文
2008年8月23日
写了一半 现在只能下棋 还不能判断
package day04;
import java.util.Scanner;
public class FiveChess {
public static void main(String[] args) {
char[][] state=new char[14][14];
for(int i=0;i<state.length;i++){
for(int j=0;j<state[i].length;j++){
state[i][j]='*';
}
}
boolean isBlack=true;//当前是黑方下子
Scanner sca=new Scanner(System.in);
printState(state);
while(true){
System.out.println("请"+(isBlack?"黑":"白")+"方下子:");
String input=sca.next();
if(input.equals("exit")){
break;
}
int x=input.charAt(0)-'a';
int y=input.charAt(1)-'a';
if(state[x][y]=='@' || state[x][y]=='O'){//该位置已经有棋子了
System.out.println("该位置已经有棋子,请重新指定坐标!");
continue;
}
state[x][y]=(isBlack?'@':'O');
printState(state);
if(isWin(state,isBlack,x,y)){
System.out.println((isBlack?"黑":"白")+"方获胜!");
break;
}
isBlack=!isBlack;
}
}
public static void printState(char[][] state){
for(int i=0;i<state.length;i++){//输出每一行的内容
System.out.print((char)('a'+i)+" ");//输出行坐标(左边的字母)
for(int j=0;j<state[i].length;j++){//输出该行的内容
System.out.print(state[i][j]+" ");
}
System.out.print("\n");//输出换行符
}
System.out.print(" ");//输出第一行开头的空格
for(int i=0;i<state[0].length;i++){//输出第一行的所有字母
System.out.print((char)('a'+i)+" ");
}
System.out.print("\n");//输出换行符
}
public static boolean isWin(char[][] state,boolean isBlack,int x,int y){
//char c=isBlack?'@':'O';
return isShuipingWin(state,isBlack,x,y) || isChuizhiWin(state,isBlack,x,y) ||
isZuoXieWin(state,isBlack,x,y) || isYouXieWin(state,isBlack,x,y);
}
public static boolean isShuipingWin(char[][] state,boolean isBlack,int x,int y){
//?????
return false;
}
public static boolean isChuizhiWin(char[][] state,boolean isBlack,int x,int y){
//?????
return false;
}
public static boolean isZuoXieWin(char[][] state,boolean isBlack,int x,int y){
//??????
return false;
}
public static boolean isYouXieWin(char[][] state,boolean isBlack,int x,int y){
//??????
return false;
}
}
2008年3月28日
import java.util.*;
public class Bool
{
public static void main(String args[])
{
Random rand= new Random ();
int i=rand.nextInt()%100;
int j=rand.nextInt()%100;
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("i>j is "+(i>j));
System.out.println("i<j is "+(i<j));
System.out.println("i>=j is "+(i>=j));
System.out.println("i<=j is "+(i<=j));
System.out.println("i==j is "+(i==j));
System.out.println("i!=j is "+(i!=j));
System.out.println("(i<10)&&(j<10) is "+((i<10)&&(j<10)));
System.out.println("(i>10)||(j>10) is "+((i>10)||(j>10)));
}
}
public class guanxi
{
public static void main (String args[])
{
float a=10.0f;
double b=10.0;
if(a==b)
{
System.out.println("a和b相等");
}
else
{
System.out.println("a和b不相等");
}
}
}
public class autoinc
{
public static void main (String[] args){
int i= 1;
System.out.println("i:"+i);
System.out.println("++i:"+ ++i);
System.out.println("i++:"+ i++);
System.out.println("i:"+i);
System.out.println("--i:"+ --i);
System.out.println("i--:"+ i--);
System.out.println("i:"+i);
}
}
2008年3月25日
public class SimpleTypes {
public static void main (String args [])
{
byte b=0x55;
short s=0x55ff;
int i=1000000;
char c='c';
float f=0.23f;
double d=0.7E-3;
boolean bool=true;
System.out.println("b="+b);
System.out.println("s="+s);
System.out.println("i="+i);
System.out.println("c="+c);
System.out.println("f="+f);
System.out.println("d="+d);
System.out.println("bool="+bool);
}
}
/**
* @算术运算符的运算
*/
public class suanshu{
public static void main (String args[])
{
int a=5+4;
int b=a*2;
int c=b/4;
int d=b-c;
int e=-d;
int f=e%4;
double g=18.4;
double h=g%4;
int i=3;
int j=i++;
int k=++i;
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("c="+c);
System.out.println("d="+d);
System.out.println("e="+e);
System.out.println("f="+f);
System.out.println("g="+g);
System.out.println("h="+h);
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("k="+k);
}
}
2008年3月22日
<%@ page import="test.TestBean"%>
<html>
<body>
<center>
<% TestBean testBean=new TestBean("This is a test java bean.");%>
java bean name is ;
<%=testBean.getName() %>
</center>
</body>
</html>
package test;
public class TestBean{
private String name=null;
public TestBean(String strName_p){
this.name=strName_p;
}
public void setName(String strName_p){
this.name=strName_p;
}
public String getName(){
return this.name;
}
}
set path=%java_Home%\bin
set classpath=jar包的路径;jar包的路径
javac *.java
pause
package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
pulic class Test extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
PrintWriter out=response.getWriter();
out.println("<html><body><h3>This is a servlet test.</h3></body></html>");
out.flush();
}
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
******
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<description>
A application for test
</description>
<servlet>
<servlet-name>Test</servlet-name>
<display-name>Test</display-name>
<description>
A test for servlet.
</description>
<servlet-class>test.Test</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/Test</url-pattern>
</servlet-mapping>
</web-app>
\myapp\WEB-INF\classes\test
http://www.eclipse.org
http://www.apache.org
2008年3月21日
宿舍新安装上宽带,闲暇时上网,无意中找到了高中时代的同桌一鸣。日子过的好快,还记得高一的时候我们两个人早上起来一起学习英语的事情……………………