网站首页 > 文章中心 > 其它

java对阵场次的源代码

作者:小编 更新时间:2023-12-12 12:34:32 浏览量:497人看过

现在有偶数支球队进行单循环比赛,请用JAVA编写出他们对阵的形式,并打印出来.

public class FootballScheduleDemo {

public static void main(String[] args) {

java对阵场次的源代码-图1

Team[] tms=new Team[tLen];

for(int i=0; itLen; i++){

tms[i]=new Team();

tms[i].name="Team["+(i+1)+"]";

}

Team h=tms[i];

for(int j=0; jtLen; j++){

if(i==j)

continue;

Team a=tms[j];

System.out.println(h.name+" vs "+a.name);

java对阵场次的源代码-图2

static class Team{

String name;

编排出有5人(或队)参加的单循环比赛的轮次和每个轮次的场次(即对阵形式)

用赛事管理系统可以解决

①新建一个单循环对阵

java射击世界杯足球赛成绩统计

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

import javax.swing.table.*;

import java.sql.*;

public class BrowseJFrame extends JFrame implements ListSelectionListener

{

private DataBaseOperation dboper; //操纵数据库的对象

private String table; //数据库中的表名

private String[] columnNames; //指定表中所有列的中文标题

private String list_column; //表中的列

private String sort_column; //指定排序依据的列

private JList list_group; //列表框,显示分类列的不重复值

private JTable table_team; //表格组件,显示数据库中指定的内容

private DefaultTableModel tableModel; //JTable使用的模式

public BrowseJFrame(DataBaseOperation dboper, String table, String[] columnNames, String list_column, String sort_column) //构造方法,指定表名

this.dboper = dboper;

this.table = table;

this.columnNames = columnNames;

this.list_column = list_column;

this.sort_column = sort_column;

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

JSplitPane splitter_h = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); //分割窗格,水平分割

this.add(splitter_h);

try

String[] groupdata = dboper.selectDistinct(table, list_column); //获得指定列不重复的值

this.list_group = new JList(groupdata);

this.list_group.setSelectedIndex(1); //选中第1项

splitter_h.add(new JScrollPane(this.list_group));

this.list_group.addListSelectionListener(this); //注册选择事件监听器

tableModel = new DefaultTableModel(columnNames,0); //默认表格模式

this.valueChanged(null); //执行列表框的选择事件处理程序

this.table_team = new JTable(tableModel);

// this.table_team.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

splitter_h.add(new JScrollPane(table_team));

catch(Exception e)

e.printStackTrace();

this.setVisible(true);

String conditions="";

if(columnValue!=null !columnValue.equals("全部"))

conditions = this.list_column + " = '"+columnValue+"'";

dboper.select(this.table, conditions, sort_column, this.tableModel); //查询并显示指定组的数据结果集

catch(SQLException sqle)

sqle.printStackTrace();

public void valueChanged(ListSelectionEvent e) //在列表框中选择数据项时触发

{ //在表中查询指定组的数据,将数据结果集显示在表格组件中

String selecteditem = (String)list_group.getSelectedValue();

if(selecteditem!=null)

public static void main(String args[])

String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //指定SQL Server JDBC驱动程序

String user = "sa"; //指定用户名

String password = "yeheya"; //指定用户口令

DataBaseOperation dboper = new DataBaseOperation(driver,url,user,password);

BrowseJFrame team_browse = new BrowseJFrame(dboper,"MatchRecord", team_columnNames, "group1", "number");

/*

//小组赛记录表

//小组赛积分榜

String[] team_columnNames={"排名","组别","球队","国旗","场次","胜","平","负","进球","失球","净胜球","积分"};

BrowseJFrame team_browse = new BrowseJFrame(dboper,"TeamScore", team_columnNames, "group1", "rank");

{ //在表中查询指定组的数据,将数据结果集显示在表格组件中

java对阵场次的源代码-图3

String conditions = this.list_column + " = '"+selecteditem+"'";

dboper.select(this.table, conditions, sort_column, this.dataModel); //查询并显示指定组的数据结果集

*/有点东西需要发给你

编写java程序:输入一组整数存放在数组中,比较并输出其中最大值和最小值,并将数组

public class Arr{

//数组

//对数组进行简单的排序

java.util.Arrays.sort(arr);

//输出最大值、最小值

System.out.println("最大值:" + arr[arr.length-1] +"\n最小值:" + arr[0]);

//从小到大输出

System.out.println(java.util.Arrays.toString(arr));

如何用JAVA设计一个游戏,电脑和人玩剪刀石头布游戏,并且能显示游戏结果?

写了一下,结果输出到桌面上,你把文件输出路径改成你的桌面路径就可以了,不知道你要不要最终结果

代码:

package com.hmall;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

import java.util.Scanner;

/**

* @ClassName Mora

* @Description TODO

* @Author dell

* @Version 1.0

**/

public class Mora {

private static String calculate(String input) {

ListString list = new ArrayList();

list.add("拳头");

list.add("剪刀");

list.add("布");

Random r = new Random();

String temp = list.get(random);

if (temp.equals(input)) {

return "您出了" + input + ",电脑出了" + temp + ",结果为平局";

} else {

if (input.equals("拳头")) {

if (temp.equals("剪刀")) {

return "您出了" + input + ",电脑出了" + temp + ",结果为您赢了";

return "您出了" + input + ",电脑出了" + temp + ",结果为您输了";

} else if (input.equals("剪刀")) {

if (temp.equals("拳头")) {

} else if (input.equals("布")) {

return "输入数据有误";

Scanner scanner = new Scanner(System.in);

Integer count;

while (true) {

count = scanner.nextInt();

System.out.println("比赛开始");

break;

String input;

File f = new File("C:\\Users\\dell\\Desktop\\result.txt");

try {

BufferedWriter bw = new BufferedWriter(new FileWriter(f));

for (int i = 0; i count; i++) {

System.out.println("请输入您的选择:");

input = scanner.next();

String result = calculate(input);

bw.write(result);

bw.newLine();

System.out.println(result);

bw.close();

} catch (IOException e) {

结果:

以上就是土嘎嘎小编为大家整理的java对阵场次的源代码相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!

版权声明:倡导尊重与保护知识产权。未经许可,任何人不得复制、转载、或以其他方式使用本站《原创》内容,违者将追究其法律责任。本站文章内容,部分图片来源于网络,如有侵权,请联系我们修改或者删除处理。

编辑推荐

热门文章