/*
Volleyball Scoring Board
*/
Design Ideas : I This volleyball scoreboard is the use of object-oriented thinking to write, game class inside defines a lot of methods and variables encapsulated into a class, through the call between methods to achieve the scoring function,
It is implemented by using the If ElseIf, if else, equals, for loops, and other loops and methods.
Code section:
Game.java
Package Biyesheji;
Import Java.util.Scanner;
public class Game {
Scanner input=new Scanner (system.in); User-Entered Scanner class
int REDJF; Defines the integral of an int type Red Square
int BLUEJF; Defines the integral of an int type Blue square
int Bsls; Define an int type wheel number
int REDCJ; Define an int type Red Square wheel number result integral
int BLUECJ; Define an int type Red Square wheel number result integral
public string Price () {//defines a string-type price method with a return value
String A=input.next (); User enters a character
return A; Returns a string of type a
}
public int sr () {
int B=input.nextint (); The user enters B of type int and then returns
return b;
}//Li Xin
public void Jifen () {
System.out.println ("\ T" + "Welcome to the volleyball scoring system"); User input
System.out.println ("******************************");
System.out.println ("1. Competition is divided into blue and red side");
System.out.println ("2. Competition for three innings and two wins system");
System.out.println ("3. Which side of a game first achieves 3 minutes of a single victory");
System.out.println ();
System.out.println ("scoring starts?") Start y/n exit ");
if (Price () equals ("Y")) {//Enter Y to continue entering N exit return
System.out.println ("Blue Square score Please press: 1 Red Square score Press: 2");
Match ();
}else{
SYSTEM.OUT.PRINTLN ("program is about to exit, welcome to use next!") ");
}
}
public void Match () {
for (int s=1;s<=3;s++) {
redjf=0; Red and Blue square points zeroed
bluejf=0;
if (redcj>=2| | bluecj>=2) {
System.out.println ("The full end! ");
SYSTEM.OUT.PRINTLN ("Final result: Red Square" +redcj+ ":" +bluecj+ "Blue Square");
if (REDCJ>BLUECJ) {
System.out.println ("The Red side won the final victory!") Great ");
}else{
System.out.println ("Blue side wins the final victory!") Great ");
}
Return
}else{
dlbs (); Execute dlbs (); method
}
}
}
public void dlbs () {
SYSTEM.OUT.PRINTLN ("-----" + (bsls+1) + "round------");
for (int i=0;i<=3;i++) {
if (redjf==3| | bluejf==3) {
Judge (); Calling the Judge method
Break
}else{
System.out.println ("the" + (i+1) + "bureau");
System.out.print ("Please enter victory Party:");
Ji (); Call the Ji () method
}
}
}
public void Ji () {
int S=SR ();
if (s==1) {
System.out.println ("Blue Square victory + 1 points!") ");
bluejf++;
System.out.println ("Red Square" +redjf+ ":" +bluejf+ "Blue Square");
}else if (s==2) {
System.out.println ("Red Square victory + 1 points!") ");
redjf++;
System.out.println ("Red Square" +redjf+ ":" +bluejf+ "Blue Square");
}
System.out.println ();
}
public void judge () {
System.out.println ("The game is over! ");
System.out.println ("match result: Red Square" +redjf+ ":" +bluejf+ "Blue Square");
if (REDJF>BLUEJF) {
System.out.println ("Red side wins!") ");
redcj++;
}else{
SYSTEM.OUT.PRINTLN ("Lanfangshen! ");
bluecj++;
}
System.out.println ();
bsls++;
}
}
Test.java
Package Biyesheji;
public class Test {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
Game Ga=new game ();
Ga.jifen ();
Ga.match ();
}
}
Operating effect:
Volleyball Scoring Board