Games, quick keys, games, and keys

Source: Internet
Author: User

Games, quick keys, games, and keys

I wrote a very simple game, but I still can't play it, but I can just change it to pass the customs. I can write better, but I am too lazy to modify it. Now I write a game myself, though it is very simple. However, I know more about games. In fact, all games are just a bunch of data, but they can be so fascinating. The game is not well written. But I feel a lot!

A little more nonsense. Enter the topic. Write a project? Both analyze the project requirements first. Today we are writing about games. (In the development environment MyEclipse2014, I will write a blog post from configuring environment variables to cracking if I have time !)

Code in both hands

These are the required classes.

 

No Comments (comments are for others, but such a simple code will not be written, mainly because I am lazy )!

 1 package cn.curry.day05; 2  3 public class Player { 4     private int levelNo; 5     private int curScore; 6     private long starTime; 7     private int elapsedTime; 8     public int getLevelNo() { 9         return levelNo;10     }11     public void setLevelNo(int levelNo) {12         this.levelNo = levelNo;13     }14     public int getCurScore() {15         return curScore;16     }17     public void setCurScore(int curScore) {18         this.curScore = curScore;19     }20     public long getStarTime() {21         return starTime;22     }23     public void setStarTime(long starTime) {24         this.starTime = starTime;25     }26     public int getElapsedTime() {27         return elapsedTime;28     }29     public void setElapsedTime(int elapsedTime) {30         this.elapsedTime = elapsedTime;31     }32     public void play() {33         Game game=new Game();34         game.printResult();35     }36 37 }
Package cn. curry. day05; import java. util. random; import java. util. secret; public class Game {private Player player = new Player (); public Player getPlayer () {return player;} public void setPlayer (Player player Player) {this. player = player;} extends inputpipeline = new pipeline (System. in); public String printStr (int levelNo) {StringBuffer sBuffer = new StringBuffer (); int strLength = LevelParam. level [levelNo-1]. GetStrLength (); Random random = new Random (); for (int j = 0; j <strLength; j ++) {int rand = random. nextInt (strLength); switch (rand) {case 0: sBuffer. append (">"); break; case 1: sBuffer. append ("<"); break; case 2: sBuffer. append ("*"); break; case 3: sBuffer. append ("&"); break; case 4: sBuffer. append ("%"); case 5: sBuffer. append ("#"); break;} return sBuffer. toString ();} public void printResult () {long starTime = Sys Tem. currentTimeMillis (); player. setStarTime (starTime); for (int I = 1; I <= LevelParam. level. length; I ++) {starTime = System. currentTimeMillis (); int count = 0; int allScore = 0; for (int j = 0; j <= count; j ++) {String liveChar = printStr (LevelParam. level [I-1]. getLevalNo (); System. out. println (liveChar); String startChar = inputsecond. next (); int score = LevelParam. level [I-1]. getPerScore (); long next Time = System. currentTimeMillis (); long useTime = (nextTime-starTime)/1000; if (nextTime-player. getStarTime ()/1000> LevelParam. level [I-1]. getTimeLinit () {System. out. println ("your input is too slow, time-out, the game is over"); System. exit (1);} if (liveChar. equals (startChar) {System. out. println ("correct input"); allScore + = score; count ++; System. out. println ("entered correctly, your level" + LevelParam. level [I-1]. getLevalNo () + ", your points" + allScore + "used "+ UseTime);} else {System. out. println (" incorrect input. The game is over! "); System. exit (1);} if (count = LevelParam. level [I-1]. getStrTime () {long thenTime = System. currentTimeMillis (); player. setStarTime (thenTime); break;} else {continue ;}} System. out. println ("Congratulations! Game clearance! ");}}

  

package cn.curry.day05;public class Level {private int levalNo;private int strLength;private int strTime;private int timeLinit;private int perScore;public Level(int levalNo, int strLength, int strTime, int timeLinit,int perScore) {this.levalNo = levalNo;this.strLength = strLength;this.strTime = strTime;this.timeLinit = timeLinit;this.perScore = perScore;}public int getLevalNo() {return levalNo;}public void setLevalNo(int levalNo) {this.levalNo = levalNo;}public int getStrLength() {return strLength;}public void setStrLength(int strLength) {this.strLength = strLength;}public int getStrTime() {return strTime;}public void setStrTime(int strTime) {this.strTime = strTime;}public int getTimeLinit() {return timeLinit;}public void setTimeLinit(int timeLinit) {this.timeLinit = timeLinit;}public int getPerScore() {return perScore;}public void setPerScore(int perScore) {this.perScore = perScore;}}

  

package cn.curry.day05;public class LevelParam {public final static Level level[]=new Level[6];static{level[0]=new Level(1,2,10,30,1);level[1]=new Level(2,3,9,26,2);level[2]=new Level(3,4,8,22,5);level[3]=new Level(4,5,7,18,8);level[4]=new Level(5,6,6,15,10);level[5]=new Level(6,7,5,12,15);}}

  

package cn.curry.day05;public class Test {    public static void main(String[] args) {        Player player=new Player();        player.play();    }}

There are too many disadvantages, and many bugs are not adjusted. In short, the code is very bad. But I can still use it for reference!

It's just about communicating and learning from each other. Writing worse is what I wrote, and this is a reflection of my thoughts. I will make progress, but learning is not that difficult. A young cow who hasn't learned JAVA for a few days!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.