µ¶Ê¯Í·²¼ÓÎÏ· java°æ
import java.util.Scanner;
public class Game{
void welcome(){
println("»¶ÓÀ´µ½¼ôµ¶Ê¯Í·²¼ÓÎÏ·");
}
Choice getUserChoice(){
println("ÇëÑ¡Ôñ\t[1]¼ôµ¶\t[2]ʯͷ\t[3]²¼");
Scanner sc= new Scanner(System.in);
int userChoice=Integer.parseInt(sc.nextLine());
while(userChoice>3||userChoice<1){
println("ÄúÊäÈëµÄ²»ºÏ·¨£¬ÇëÖØÐÂÊäÈë");
userChoice=Integer.parseInt(sc.nextLine());
}
return new Choice(userChoice);
}
Choice getComputerChoice(){
return new Choice((int)(3*Math.random())+1);
}
void showResult(Choice userChoice,Choice computerChoice){
int re=userChoice.compareTo(computerChoice);
if(re==0){
println("ƽÁË!ÄúºÃ,ÄúÊäÈëµÄÊÇ:"+userChoice.getText());
}else if(re==1){
println("¹§Ï²Äú»ñʤÁË£¡ÄúÊäÈëµÄÊÇ:"+userChoice.getText()+"\tµçÄÔÊäÈëµÄÊÇ:"+computerChoice.getText());
}
else {
println("±§Ç¸ÄúÊäÁË£¡ÄúÊäÈëµÄÊÇ:"+userChoice.getText()+"\tµçÄÔÊäÈëµÄÊÇ:"+computerChoice.getText());
}
}
void println(String s){
System.out.println(s);
}
void start(){
welcome();
Choice userChoice=getUserChoice();
Choice computerChoice=getComputerChoice();
showResult(userChoice,computerChoice);
}
public static void main(String[] args){
new Game().start();
}
}
class Choice{
String s[]={"¼ôµ¶","ʯͷ","²¼"};
int value;
Choice(int a){
value=a;
}
String getText(){
return s[value-1];
}
// 0Ϊ ƽ 1Ϊ Ó® -1Ϊ Êä
int compareTo(Choice c){
if(value==c.value){
&nb
Ïà¹ØÎĵµ£º
ÀàµÄ³õʼ»¯ºÍ¶ÔÏó³õʼ»¯ÊÇ JVM ¹ÜÀíµÄÀàÐÍÉúÃüÖÜÆÚÖзdz£ÖØÒªµÄÁ½¸ö»·½Ú£¬Google ÁËÒ»±éÍøÂ磬ÓйØÀà×°ÔØ»úÖÆµÄÎÄÕµ¹ÊDz»ÉÙ£¬È»¶øÀà³õʼ»¯ºÍ¶ÔÏó³õʼ»¯µÄÎÄÕ²¢²»¶à£¬ÌرðÊÇ´Ó×Ö½ÚÂëºÍ JVM ²ã´ÎÀ´·ÖÎöµÄÎÄÕ¸üÊÇÏÊÓÐËù¼û¡£
±¾ÎÄÖ÷Òª¶ÔÀàºÍ¶ÔÏó³õʼ»¯È«¹ý³Ì½øÐзÖÎö£¬Í¨¹ýÒ»¸öʵ¼ÊÎÊÌâÒýÈ룬½«Ô´´úÂëת»»³É JVM ×Ö½ÚÂëºó£¬ ......
1.Éú³ÉgifͼƬ¸ñʽµÄ
package com.cssweb.common.util;
import java.io.*;
import java.util.*;
import com.sun.image.codec.jpeg.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.awt.*;
import java.awt.image.*;
/*
* ¹¦ÄÜ£ºµ÷ÓÃAuthServlet¿ÉÒÔÉú³ÉÒ»¸öÑéÖ¤ÂëͼƬ,ͼƬµÄ¿í¶ÈºÍ¸ß¶È¿ÉÒ ......
½ñÌìºÍ´ó¼ÒÒ»ÆðѧϰJavaµÄÉè¼ÆÄ£Ê½¡£±¾È˵Äˮƽ²»ÊǺܸߣ¬ÕâϵÁÐÎÄÕÂÖ»ÊÇ×Ô¼ºÑ§Ï°µÄ¹ý³Ì£¬²¢Ï£ÍûÄÜͬ´ó¼Ò·ÖÏí¾Ñé¡£
ÏÈ˵ÏÂÎÒ¶Ô¹¤³§Ä£Ê½µÄÀí½â£ºµ±ÎÒÃÇÐèҪij¸ö¶ÔÏóʱ£¬×îÖ±½ÓµÄ°ì·¨ÊÇ¿´µ½Õâ¸ö¶ÔÏó¾ÍÄùýÀ´¡£µ«Êǵ±¶ÔÏó·Ç³£¶àµÄʱºò£¬ÕÒÆðÀ´¾ÍºÜ²»·½±ã¡£Õâʱ¾ÍÐèÒªÒ»¸öÖнéÀ´°ïÖúÎÒÃÇÈ¡µÃÏëÒªµÄ¶«Î÷£¬Õâ¸öÖнé¾ÍÊǹ¤³§£¨fa ......
package test;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
public class XmlTest {
public static void main(String[] args) {
File xmlFile=new File("test/xml.xml");
DocumentBuilderFactory documentBuilderFactor ......