球赛管理系统java代码 球赛管理系统java代码大全
用JAVA怎么编写停车场管理系统源代码?
importjava.text.SimpleDateFormat;\x0d\x0aimportjava.util.Date;\x0d\x0aimportjava.util.Scanner;\x0d\x0a\x0d\x0a/*********************************\x0d\x0a*停车场管理\x0d\x0a*authorzhang\x0d\x0a*2013-12-13\x0d\x0a********************************/\x0d\x0apublicclassCarStopManager{\x0d\x0a\x0d\x0apublicstaticvoidmain(String[]args){\x0d\x0aScannersc=newScanner(System.in);\x0d\x0a\x0d\x0aSystem.out.println("请入车牌号:");\x0d\x0aStringcarno=sc.next();\x0d\x0aCarStopManagercarStopManager=newCarStopManager();\x0d\x0acarStopManager.setCarNo(carno);//设置车牌号\x0d\x0a\x0d\x0aSimpleDateFormatformat=newSimpleDateFormat("yyyy-MM-ddHH:mm:ss");\x0d\x0aStringsdate=format.format(newDate());\x0d\x0aSystem.out.println("当前时间(入场时间)是:"+sdate);\x0d\x0a\x0d\x0aSystem.out.println("需要开出车场吗?yes/no:");\x0d\x0aStringyesno=sc.next();\x0d\x0a\x0d\x0aif(yesno.equals("yes")){\x0d\x0aStringedate=format.format(newDate());\x0d\x0aSystem.out.println("出场时间是:"+edate);\x0d\x0a//计算方法\x0d\x0acarManager(2,sdate,edate,carStopManager);\x0d\x0a}\x0d\x0a}\x0d\x0a/**\x0d\x0a*计算方法\x0d\x0a*/\x0d\x0apublicstaticvoidcarManager(inttype,StringstarTime,\x0d\x0aStringendTime,CarStopManagercarStopManager){\x0d\x0a\x0d\x0aif(type==1){//按月收费\x0d\x0aSystem.out.println("如若没有缴纳月费请缴纳800元,如若缴纳将不再提示!");\x0d\x0a}else{\x0d\x0a/**\x0d\x0a*一般不会有停车几个月的吧?先不考虑停车几年或者几个月的\x0d\x0a*/\x0d\x0aStringsDay=starTime.substring(8,10);//入场日期(天)\x0d\x0aStringsHour=starTime.substring(11,13);//入场小时\x0d\x0aStringsMM=starTime.substring(14,16);//入场分钟\x0d\x0a\x0d\x0aStringeDay=starTime.substring(8,10);//出场日期(天)\x0d\x0aStringeHour=endTime.substring(11,13);//出厂小时\x0d\x0aStringeMM=endTime.substring(14,16);//出厂分钟\x0d\x0a\x0d\x0afloatmoney=0;//需缴纳的费用\x0d\x0aintshour=Integer.parseInt(sHour);\x0d\x0aintehour=Integer.parseInt(eHour);\x0d\x0aintsmm=Integer.parseInt(sMM);\x0d\x0aintemm=Integer.parseInt(eMM);\x0d\x0aintrehour=0;//停车几个小时\x0d\x0a\x0d\x0aif(sDay.equals(eDay)){//同一天\x0d\x0a//当天6点到20点之间\x0d\x0aif((shour=6shour
成都创新互联主营明山网站建设的网络公司,主营网站建设方案,成都app软件开发,明山h5微信小程序定制开发搭建,明山网站营销推广欢迎明山等地区企业咨询
回答于 2022-12-14
求助:循环赛—java源代码
以前的!
====代码====
package com;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
* 网球赛
* @author Cris
* @ClassName: Match
* @Version
* @ModifiedBy
* @Copyright @ 2010 HL Technology Inc.
* @date 2011-5-24 上午11:29:39
* @description
*/
public class Match implements ActionListener{
private JFrame f;
private JTextField tf;
private JPanel container;
private JList myList ;
private JLabel message;
private JButton b;
/**
* @author Cris
* @title: main
* @date 2011-5-23 上午11:07:27
* @param args void
*/
public static void main(String[] args) {
Match t = new Match();
t.go();
}
public void go(){
f = new JFrame("比赛");
f.setLocation(100, 200);
f.setSize(600,500);
container = new JPanel(new BorderLayout());
f.setContentPane(container);
JPanel title = new JPanel(new FlowLayout());
tf = new JTextField(10);
title.add(tf);
b = new JButton("确定");
b.addActionListener(this);
title.add(b);
message = new JLabel();
title.add(message);
container.add(title,BorderLayout.NORTH);
myList = new JList();
container.add(myList,BorderLayout.CENTER);
f.setVisible(true);
}
/**
* 显示比赛结果
* @author Cris
* @title: show
* @date 2011-5-24 上午11:31:05
* @param n void
*/
private void show(int n){
Cris c = new Cris(n);
ListListString[] result = c.getResult();
String[] str = new String[result.size()];
for (int i = 0; i result.size(); i++) {
StringBuilder sb = new StringBuilder();
sb.append("第").append(i+1).append("天: ");
ListString[] matchList = result.get(i);
for(String[] match : matchList){
sb.append("[").append(match[0]).append("-").append(match[1]).append("] ");
}
str[i] = sb.toString();
}
myList.setListData(str);
message.setText("");
f.setVisible(true);
}
/**
* 清空数据
* @author Cris
* @title: clear
* @date 2011-5-24 上午11:30:36 void
*/
private void clear(){
String[] str = {""};
myList.setListData(str);
message.setText("");
}
public void actionPerformed(ActionEvent e) {
clear();
String s = tf.getText();
if (s == null || "".equals(s = s.trim()) ) {
message.setText("请输入一个偶数");
}
try {
int n = Integer.parseInt(s);
if (n = 0 || n % 2 != 0) {
message.setText("请输入一个偶数");
}else{
show(n);
}
} catch (Exception ex) {
message.setText("请输入一个偶数");
}
f.setVisible(true);
}
}
第二个类:
package com;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
public class Cris {
/**选手数量*/
private int n ;
/**各个运动员还没进行的比赛 key:球员名称,value:需进行的比赛集合*/
private MapString, ListString[] playerMacth ;
/**球员人名*/
private String[] players ;
/**最终每天的比赛分布集合*/
private ListListString[] result;
/**所有可选的比赛*/
private ListListString[] allMatchData[];
/**每天的比赛*/
ListString[] dayMatch ;
/**一个随机对象*/
private Random r;
/**当前运算到的天数*/
private int nowDay;
public Cris(int n){
this.n = n;
playerMacth = new HashMapString, ListString[]();;
result = new ArrayListListString[]();
allMatchData = new LinkedList[n-1];
r = new Random();
init();
go();
}
/**
* 初始化球员
* @author Cris
* @title: init
* @date 2011-5-23 下午04:22:32 void
*/
private void init(){
//定义球员人名,以数字代表,从1开始
players = new String[n];
for (int i = 0; i players.length; i++) {
//定义球员的名字
players[i] = String.valueOf(i+1);
//存放每个球员要进行的比赛的集合
ListString[] matchList = new LinkedListString[]();
//球员赛事集合
playerMacth.put(players[i], matchList);
//球员集合,不变
// playerListConst.add(players[i]);
}
//定义每个人的比赛
for (int i = 0; i players.length -1; i++) {
for (int j = i+1; j players.length ; j++) {
String[] match = {players[i],players[j]};//定义一个比赛
//把此赛事添加到相应球员需比赛集合中
playerMacth.get(players[i]).add(match);
playerMacth.get(players[j]).add(match);
}
}
}
/**
* 随机获得一个当前天数可进行的比赛组合,并把此比赛组合从总集合中移除
* 如果当前天数无比赛,则先获得比赛,再随机
* @author Cris
* @title: getNowDayMatch
* @date 2011-5-24 上午09:48:23
* @return ListString[]
*/
private ListString[] getNowDayMatch(){
if (allMatchData[nowDay] == null) {
setAllMatchNowDay();
}
if (! allMatchData[nowDay].isEmpty()) {
int index = r.nextInt(allMatchData[nowDay].size());
ListString[] list = allMatchData[nowDay].get(index);
allMatchData[nowDay].remove(index);
return list;
}else {
return null;
}
}
/**
* 取消前一天的比赛
* @author Cris
* @title: cancelYesterday
* @date 2011-5-24 上午09:56:12 void
*/
private void cancelYesterday(){
//清空当前天数的可选比赛组合
allMatchData[nowDay] = null ;
//时间恢复到前一天
nowDay--;
//获得前一天的比赛
ListString[] matchList = result.get(nowDay);
//取消前一天的比赛
result.remove(nowDay);
//恢复每个运动员未进行的比赛
for(String[] match : matchList){
playerMacth.get(match[0]).add(match);
playerMacth.get(match[1]).add(match);
}
}
public void go(){
//循环比赛天数
for ( nowDay = 0; nowDay n -1; ) {
//1.随机一个比赛
ListString[] matchList = getNowDayMatch();
//无比赛组合 ,返回上一天 取消上一天的比赛,时间回退到前一天,跳过此次循环
if (matchList == null) {
cancelYesterday();
continue;
}
//3遍历比赛 去除运动员 去除运动员的未进行比赛
for(String[] match : matchList){
playerMacth.get(match[0]).remove(match);
playerMacth.get(match[1]).remove(match);
}
result.add(matchList);
nowDay++;
}
}
/**
* 从1号队员开始,获得当前天数所有可组合的赛事
* @author Cris
* @title: setAllMatchNowDay
* @date 2011-5-24 上午09:42:51 void
*/
private void setAllMatchNowDay(){
allMatchData[nowDay] = new LinkedListListString[]();
int n = 1;//1号运动员
//此运动员未进行的比赛
ListString[] matchList = playerMacth.get(String.valueOf(n));
for(String[] match : matchList){
ListString[] selectedList = new ArrayListString[]();
selectedList.add(match);
doDetAllMatchNowDay(n+1, selectedList);
}
}
/**
* 今天比赛的所有组合
* @author Cris
* @title: doDetAllMatchNowDay
* @date 2011-5-24 上午09:46:05
* @param playerNum
* @param selectedList void
*/
private void doDetAllMatchNowDay(int playerNum,ListString[] selectedList){
//运动员名称
String player = String.valueOf(playerNum);
boolean flag = true;
//判断此运动员是不是已被选过
for(String[] match : selectedList){
if (match[0].equals(player) || match[1].equals(player)) {
flag = false;
break;
}
}
//已被选过
if ( flag == false) {
//最后一个人员
if (playerNum == n) {
allMatchData[nowDay].add(selectedList);
}else{
doDetAllMatchNowDay(playerNum+1, selectedList);
}
return;
}
//此运动员未进行的比赛
ListString[] matchList = playerMacth.get(player);
//此运动员可选择的比赛
ListString[] canDoList = new ArrayListString[]();
for(String[] match : matchList){
flag = true;
for(String[] selected : selectedList){
if(match[0].equals(player)){
if(match[1].equals(selected[0])){
flag = false;
}else if(match[1].equals(selected[1])){
flag = false;
}
}else{
if(match[0].equals(selected[0])){
flag = false;
}else if(match[0].equals(selected[1])){
flag = false;
}
}
}
if (flag) {
canDoList.add(match);
}
}
//遍历此运动员可选择的比赛
for(String[] match : canDoList){
ListString[] newList = copyArrayList(selectedList);
//记录当前比赛
newList.add(match);
//最后一个人员
if (playerNum == n) {
allMatchData[nowDay].add(newList);
}else{
doDetAllMatchNowDay(playerNum+1, newList);
}
}
}
/**
* 复制集合
* @author Cris
* @title: copyArrayList
* @date 2011-5-24 上午09:24:44
* @param list
* @return ListString[]
*/
private ListString[] copyArrayList(ListString[] list){
ListString[] newList = new ArrayListString[]();
for(String[] s : list){
newList.add(s);
}
return newList;
}
public ListListString[] getResult() {
return result;
}
}
用java编写小程序,已知a、b、c 3个队伍进行足球比赛,胜利3记分,平局1分,输0分
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class Test {
public static void main(String[] args) {
final String[] str = { "a-b 1:1", "a-c 2:1", "b-c 0:1" };
final MapString, Integer map = new HashMapString, Integer();
for (String s : str) {
final String[] temp = s.split(" ");
final String[] names = temp[0].split("-");
final String[] counts = temp[1].split(":");
for (int i = 0; i 2; i++) {
String name = names[i];
int count = Integer.parseInt(counts[i]);
if (map.containsKey(name)) {
map.put(name, map.get(name) + count);
} else {
map.put(name, count);
}
}
}
final ListTeam teams = new LinkedListTeam();
for (String name : map.keySet()) {
teams.add(new Team(name, map.get(name)));
}
Collections.sort(teams);
System.out.println("队伍 : 分");
for (Team t : teams) {
System.out.println(t.getName() + " : " + t.getCount());
}
}
}
class Team implements ComparableTeam {
private String name;
private int count;
public Team(String name, int count) {
this.name = name;
this.count = count;
}
public void addCount(int count) {
this.count = this.count + count;
}
public String getName() {
return name;
}
public int getCount() {
return count;
}
public int compareTo(Team o) {
return o.getCount() - this.count;
}
}
java足球赛有多少场并列出运算
很明显,就拿世界杯小组赛来说 4个队比赛,共6场
这是数学的组合知识.相当于从4里面选2个队比赛
同样 从14个里面选出2个队比赛 共是91场比赛
题目有点小问题.
简单点,式子就是 14*13/2=91
如何做一个java管理系统
首先你打算用什么技术来实现这个系统,先想好用哪些东西,是纯粹的jsp,servlet+javabean还是用到struts,spring等框架,将用到的技术想到后,再进行下一步.
其次你要搭建基于你使用的开发技术的环境,如果用jsp,servlet,javabean的话只需要个tomcat类似的容器就行了,如果要用到struts或者spring等相关的框架的话,就去下载相关的文件,如果用EJB的话,去装个jboss或者weblogic等EJB容器.
再次,环境搭建好之后就进入真正的开发了,进行需求分析,uml建模,设计好层次结构,然后进行编码,编码好后进行测试,不断改进,最后交付使用了.
呵呵,如果你不懂的话现看看相关的资料再进行开发,不要茫无目的的动手编码。
求用Java编写的学生成绩管理系统的完整代码
package jdbcproj;
import java.sql.*;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.awt.event.ActionEvent;
public class MainFrame extends JFrame {
private JPanel contentPane;
private JTextField txtname;
private JTextField txtpassword;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MainFrame frame = new MainFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MainFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 661, 399);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel("\u7528\u6237\u540D");
lblNewLabel.setBounds(114, 51, 72, 18);
contentPane.add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("\u5BC6\u7801");
lblNewLabel_1.setBounds(114, 106, 72, 18);
contentPane.add(lblNewLabel_1);
txtname = new JTextField();
txtname.setBounds(261, 48, 86, 24);
contentPane.add(txtname);
txtname.setColumns(10);
txtpassword = new JTextField();
txtpassword.setBounds(261, 103, 86, 24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);
JButton btnadd = new JButton("\u589E\u52A0");
btnadd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45, 205, 113, 27);
contentPane.add(btnadd);
JButton btndelete = new JButton("\u5220\u9664");
btndelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAO usdo=new UserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172, 205, 113, 27);
contentPane.add(btndelete);
JButton btnupdate = new JButton("\u4FEE\u6539");
btnupdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名和密码不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAO usdo=new UserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300, 205, 113, 27);
contentPane.add(btnupdate);
JButton btnfind = new JButton("\u67E5\u8BE2");
btnfind.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(), "用户名不能为空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Users u=new Users();
UserDAO usdo=new UserDAO();
u=usdo.findUser(txtname.getText(), txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(), "该用户存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(), "该用户不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427, 205, 113, 27);
contentPane.add(btnfind);
//记得要写这个
setVisible(true);
}
}
网页标题:球赛管理系统java代码 球赛管理系统java代码大全
网页网址:http://pwwzsj.com/article/hgojig.html