结队项目-黄金点游戏

黄金点游戏是一个数字小游戏,其游戏规则是:
N个同学(N通常大于10),每人写一个0~100之间的有理数 (不包括0或100),交给裁判,裁判算出所有数字的平均值,然后乘以0.618(所谓黄金分割常数),得到G值。提交的数字最靠近G(取绝对值)的同学得到N分,离G最远的同学得到-2分,其他同学得0分。玩了几天以后,大家发现了一些很有意思的现象,比如黄金点在逐渐地往下移动。

1.运行结果:

2.创建GoldPoint类和person 类,部分代码如下:

GoldPoint类:

package GoldPoint; import java.util.Scanner; publicclass GoldPoint {static Person persons[]; privatestaticint SCORE_START=100; privatestaticint SCORE_INCRE=20; publicstaticvoidmain(String[] args) throws InterruptedException { // System.out.println("***************************");// System.out.println("********** ***********");// System.out.println("********* 黄金点游戏 *********");// System.out.println("********** ***********");// System.out.println("***************************"); System.out.println("游戏选项:"); while (true) { System.err.println("1、开始游戏\n2、查看当前游戏结果\n3、游戏设置\n4、退出"); Scanner scanner=new Scanner(System.in); int choice=scanner.nextInt(); switch (choice) { case1: welcome(); break; case2: showMessage(); break; case3: gameSetting(); break; case4: System.out.println("欢迎下次使用!程序即将退出!"); Thread.currentThread().sleep(2000); System.exit(0); break; default: break; } } }

 

person 类:

package GoldPoint; /** * JavaBean * @author Dimple * */publicclass Person {private String name; privateint num; privateint score; publicPerson() { // TODO Auto-generated constructor stubsuper(); } publicPerson(String tname,int tnum,int tscore) { // TODO Auto-generated constructor stubsuper(); name=tname; num=tnum; score=tscore; } public String getName() { return name; } publicvoidsetName(String name) { this.name = name; } publicintgetNum() { return num; } publicvoidsetNum(int num) { this.num = num; } publicintgetScore() { return score; } publicvoidsetScore(int score) { this.score = score; } }

3.github地址:https://github.com/Meihh/sp-third

posted @ 2017-10-11 14:01  Keiko_Hh  阅读(103)  评论(0编辑  收藏  举报