On the first iteration of the volleyball scoring system

Source: Internet
Author: User
Tags sca

The first iteration of the tournament system was written in the Java language, because the technology is limited, so you can only choose to interact with the user on the console without the interface. As the study progresses further, the interface is used to simplify the operation.

 PackageGame.volleyball;ImportJava.util.Scanner;/*** Volleyball Scoring System * * The use of the DD scoring system can be used to perform a simple volleyball scoring operation and check the score of a certain bureau. * 1, a total of 5 innings, each of 5 points, if one side lead each other 3 points, it is considered the victory of this party. * After the end of the 5 innings, count the number of victories of the two parties and export the final victory to the party. and quit the program * 2, using the query function can query the past performance, output score and victory of the party*/ Public classGame {StaticScanner SCA =NewScanner (system.in); //Scorearr Array, used to hold 5 innings and two teams of single-round results    Static int[] Scorearr =New int[5] [2]; //The result array, which is used to store each round of results for easy query    StaticString[] result =NewString[5]; //to count the number of victories in two teams.    Static intNI1 = 0; Static intNi2 = 0;  Public Static voidMain (string[] args) {System.out.println ("\ n--------Welcome to the DD Volleyball scoring system--------\n\n\n"); System.out.println ("Instructions for use: Using the DD scoring system, you can perform a simple volleyball scoring operation and check the score of a particular bureau. "+" \n1, a total of 5 innings, each innings 5 points, if one side lead each other 3 points, it is considered the victory of this party. "+" \ n 5 innings after the end of the statistics of two victories, the output of the final victory of the party. and quit the program \ n "+" 2, using the query function can query the past performance, output score and victory of the party ");  for(inti = 0; I < 5;) {System.out.println ("Please select your action:"); System.out.println ("1, start scoring 2, query 3, exit the system"); //User-entered action selection            intChoose =Sca.nextint (); //if the user enters 1            if(Choose = = 1) {                //Output of the game of the first few inningsSystem.out.println ("Start Now" + (i + 1) + "innings contest"); //Call scoring Methodbounds (i); I++; } Else if(choose = = 2) {//if the user outputs 2System.out.println ("Please enter the number of offices you want to inquire:"); intCheck =Sca.nextint (); //determine if the number of user input is started                if(Result[check-1] = =NULL) {System.out.println ("The game hasn't started yet. "); } Else {                    //find the result from the arraySystem.out.println (result[check-1]); }            } Else if(choose = = 3) {//If the user enters 3, outputs the current score and exits the programSystem.out.println ("The game is over, the current score is: China team vs US team ~~~~~" + Ni1 + ":" +Ni2); System.out.println ("Thank you for using DD scoring system, welcome to use next time, Goodbye"); System.exit (0); } Else{System.out.println ("Your input is wrong, please re-enter"); }        }                //5 innings after the game is over, the game ends, the output results, and exits the programSystem.out.println ("The game is over, the current score is: Chinese team vs US team ~~~~~" + Ni1 + ":" +Ni2); if(Ni1 >Ni2) {System.out.println ("The Chinese team won the final victory."); } Else{System.out.println ("The American team won the final victory."); } System.out.println ("Thank you for using DD scoring system, welcome to use next time, Goodbye"); }    //scoring methods, statistical results     Public StaticString[] Bounds (intnum) {        inti = 0; //If both teams score less than or equal to 5        if(Scorearr[num][0] <= 5 && scorearr[num][1] <= 5) {             for(;;; i++) {System.out.println ("Please output the number of the winning party, to add points"); System.out.println ("1, Chinese team VS 2, USA"); intTeam =Sca.nextint (); if(Team = = 1) {                    //keep the results of each inningScorearr[num][0] + = 1; System.out.println ("First" + (i + 1) + "Round race end, current score for" + scorearr[num][0] + ":" + scorearr[num][1]); } Else if(Team = = 2) {scorearr[num][1] + = 1; System.out.println ("First" + (i + 1) + "Round race end, current score for" + scorearr[num][0] + ":" + scorearr[num][1]); }                if((Scorearr[num][0]-scorearr[num][1]) = = 3) {Result[num]= "+" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "Chinese team wins";                    System.out.println (Result[num]); //at the end of each round, add 1 to the final score and returnNi1 + = 1; returnresult; } Else if((Scorearr[num][1]-scorearr[num][0]) = = 3) {Result[num]= "+" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "US team wins";                    System.out.println (Result[num]); Ni2+ = 1; returnresult; }            }        } Else if(Scorearr[num][0] > scorearr[num][1]) {Result[num]= "+" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "Chinese team wins";            System.out.println (Result[num]); Ni1+ = 1; returnresult; } Else{Result[num]= "+" + (num + 1) + "innings, score for" + scorearr[num][0] + ":" + scorearr[num][1] + "US team wins";            System.out.println (Result[num]); Ni2+ = 1; returnresult; }    }}

The above code, is the basic implementation of the system, can simply achieve the accumulation of scores and the game query.

Scoring of pictures

of the query

Exit the

The system uses loops and methods, as well as the use of judgment statements. To do this kind of system, it is important to smooth the logic first.

On the first iteration of the volleyball scoring system

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.