全文预览

Java程序设计实验报告

上传者:你的雨天 |  格式:doc  |  页数:10 |  大小:121KB

文档介绍
.score =0; player .score =0; npc_score .setText( "悟空胜: 0" ); player_score .setText( "八戒胜: 0" ); npc_sign .setText( "出拳"); player_sign .setText( "出拳"); }} N pc类: package Game_guessFist; import java.util.Random; class Npc{ private Random r; Npc() {r=new Random(); }public int score ; public int score1 ; public String shouFist(){ int id =Math. abs (r.nextInt())%3; String fist =null ; switch (id){ case 0: fist ="剪刀";break ;case 1: fist ="石头";break ;case 2: fist ="布";break ;}return fist; }}Player 类: package Game_guessFist; public class Player {public int score ; public String shouFist( int id ){ String fist =null ; switch (id){ case 0: fist ="剪刀"; break ;case 1: fist ="石头";break ;case 2: fist ="布";break ;}return fist; }}3、实验心得体会: 通过这次试验,发现了学习的不足。熟悉了 java 程序的制作及应用,以及提高了团队合作的默契。也提高了大家学习 java 的兴趣。

收藏

分享

举报
下载此文档