⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 olympicgames.java

📁 A system to manage the competitions of the XXth Olympic Games.
💻 JAVA
字号:
package games;

import java.util.*;

public class OlympicGames {
	
	private Map competitions = new HashMap();

	public void addCompetition(String name, String venue) {
		competitions.put(name, new Competition(name, venue));
	}

	public String getVenue(String competition) throws NoSuchCompetition {
		Competition c = (Competition)competitions.get(competition);
		
		if(c == null)
			throw new NoSuchCompetition();
		
		return c.getVenue();		
	}

	public void addAthlete(String competition, String name, int number, String country) {
		
		Competition c = (Competition)competitions.get(competition);
		
		if(c == null)
			return;
		
		c.addAthlete(name, number, country);
	}
	
	public String getName(String competition, int number) {
		
		Competition c = (Competition)competitions.get(competition);
		
		if(c == null)
			return "";
		
		return c.getName(number);
	}

	public void setTime(String competition, int athlete, int seconds) {
		
		Competition c = (Competition)competitions.get(competition);
		
		if(c == null)
			return;
		
		c.setTime(athlete, seconds);
	}
	
	public String getOrder(String competition) {
		
		Competition c = (Competition)competitions.get(competition); 
		
		if(c == null)
			return "";
		
		return c.getOrder();
	}
	
	public int count(String athlete) {
		
		int count = 0;
		
		for(Iterator i = competitions.values().iterator(); i.hasNext();){
			Competition c = (Competition)i.next();
			
			if(c.contains(athlete))
				++count;
		}
		
		return count;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -