473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

java beginner

50
I am a java beginner and as a task I was given to implement a champions league second phase draws. The program that I am going to implement must contain the following classes:

Team – This class will contain the name of the team as well as the country of the
team and qualifying group
✔ Pot – This class will contain 8 instances of the class team
✔ DrawEngine – This class will contain the main draw strategy. In our case it will
contain the two instances of class Pot. It will be responsible to implement the rules
of the draw (country checking etc.)
✔ Draw – This class contains the two teams drawn against each other. Your
application should finally produce eight instances of this class.

The rules for the champions league game are the following:

 Teams coming from the same country may not be picked up against each other.
 Teams from the same group may not be drawn against each other.

I started implementing the Team class and I have done the following:

public class Team {

String name;
String country;
Double luckFactor;
Double strength;

Team TeamsInPot1 = new Team[8];

teamInPot1[0] = new Team ("Manchester United");
teamInPot1[1] = new Team ("Real Madrid");
teamInPot1[2] = new Team ("Liverpool");
teamInPot1[3] = new Team ("Milan");
teamInPot1[4] = new Team ("Inter");
teamInPot1[5] = new Team ("Birkirkara");
teamInPot1[6] = new Team ("Barcelona");
teamInPot1[7] = new Team ("Brussels");

teamInPot1[0].country = "England";
teamInPot1[1].country = "Germany";
teamInPot1[2].country = "England";
teamInPot1[3].country = "Italy";
teamInPot1[4].country = "Italy";
teamInPot1[5].country = "Malta";
teamInPot1[6].country = "Spain";
teamInPot1[7].country = "Belgium";

Team TeamsInPot2 = new Team[8];

teamInPot2[0] = new Team ("Chelsea");
teamInPot2[1] = new Team ("Juventus");
teamInPot2[2] = new Team ("Lisbona");
teamInPot2[3] = new Team ("Leeds");
teamInPot2[4] = new Team ("SKV ");
teamInPot2[5] = new Team ("Berlin ");
teamInPot2[6] = new Team ("Paris");
teamInPot2[7] = new Team ("Valletta");

teamInPot2[0].country = "England";
teamInPot2[1].country = "Italy";
teamInPot2[2].country = "Portugal";
teamInPot2[3].country = "England";
teamInPot2[4].country = "Austria";
teamInPot2[5].country = "Germany";
teamInPot2[6].country = "France";
teamInPot2[7].country = "Malta";
}


The problem now is that I dont know how am i going to randomly generate the countries and make them obey the rules that i gave i.e. no teams of the same countries are placed against each other.

any help would be very appreciated.

thanku
Aug 8 '07 #1
6 1349
r035198x
13,262 8TB
Write the required classes as per the specs first. Remember things that you define to be inside a class have to satisfy the has-a relationship.
e.g Team has a name - correct makes sense.
Team has a Team ??? doesn't make sense.
I repeat my first sentence here for convenience:
Write the required classes as per the specs first.



P.S I hope ManU get drawn against Barcelona.
Aug 8 '07 #2
sugard
50
the required classes are Draw, DrawEngine and Pot.

public class Draw {

}

public class DrawEngine {

}

public class Pot {

}
Aug 8 '07 #3
JosAH
11,448 Expert 8TB
the required classes are Draw, DrawEngine and Pot.

public class Draw {

}

public class DrawEngine {

}

public class Pot {

}
As per your assignment text: a Draw has two teams. etc. You're supposed to
fill in that information as well.

kind regards,

Jos
Aug 8 '07 #4
sugard
50
how am i going to insert the 2 teams in draw?

As per your assignment text: a Draw has two teams. etc. You're supposed to
fill in that information as well.

kind regards,

Jos
Aug 8 '07 #5
r035198x
13,262 8TB
how am i going to insert the 2 teams in draw?
Your specs have really spoiled it all for you. The first step is to obey them. If they say a Team has a country, then define a country in the Teams class. If they say a Draw has two teams, then you need two instances of the Teams class in there. That means you need to have compiled the Team class successfully first.
Aug 8 '07 #6
JosAH
11,448 Expert 8TB
how am i going to insert the 2 teams in draw?
Spoiler alert:

Expand|Select|Wrap|Line Numbers
  1. public class Draw {
  2.    private Team teamA;
  3.    private Team teamB;
  4.    //
  5.    public Draw(Team teamA, Team teamB) {
  6.       this.teamA= teamA;
  7.       this.teamB= teamB;
  8.    }
  9.    ...
  10. }
  11.  
Now you have to craft your other classes in a similar way. That would result in
the skeletons of the classes you are about to use in your application. You have
to make some choices as well: e.g. for the Draw class, should it accept two
teams from the same country or is something else figuring that out?

kind regards,

Jos
Aug 8 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: jcnews | last post by:
I am using Windows XP and am learning how to program in Java. Is there any way to get my fonts to be anti-aliased in both editors and in my programs? The non anti-aliased fonts don't look very...
5
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech ...
6
by: Alan Brown | last post by:
As a newbie I would like to ask what the difference in application (not details) is between C++ and Java. In what situations would you use C++ in preference to Java and vice versa? I am not...
55
by: Elijah | last post by:
I have read many of the topics on learning C++ or Java first. It seems like everyone says something different. I would like to know if I should learn C++ or Java. First a little about myself. I...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
15
by: RAM | last post by:
Hello, I graduated computer science faculty and decided to became a programmer. Please help me to make a decision: Java or Microsoft .NET? What is the future of Java? Thanks! /RAM/
17
by: JD | last post by:
hi, i m new to java, i want to know if there is a good and free Java IDE that i can use that'll help me, i dont care if its complicated , i just want it to be good, i tried netbeans which comes...
6
crystal2005
by: crystal2005 | last post by:
Hello guys, I'm a beginner in Java application programming. I started to write a Java application in which link to MS Access database. I encountered a problem in deletion function. E.g. I would...
1
by: czi02 | last post by:
Im new to java. ANd somebody out there knows the tutorial of java thanx. for beginner. and how to code it???
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.