473,569 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

java beginner

50 New Member
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 1356
r035198x
13,262 MVP
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 New Member
the required classes are Draw, DrawEngine and Pot.

public class Draw {

}

public class DrawEngine {

}

public class Pot {

}
Aug 8 '07 #3
JosAH
11,448 Recognized Expert MVP
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 New Member
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 MVP
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 Recognized Expert MVP
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
8160
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 good and are a little harder on my eyes. Thanks.
5
1708
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 These are long since retired newsgroups. You may have ended up in one by
6
3856
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 asking for personal opinions on which is the *best* language :) Alan.
55
45951
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 know PHP, BASIC, and of course HTML. I'll be 15 years old in September. I am interested in programming GUI applications. I am also interested in...
11
9223
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 C++. I find my self sometimes, trying Object app = Object(); Object *app = Object(); Object app = new Object();
1
9607
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the...
15
5079
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
9364
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 bundled with java sdk 6 from sun, the prob with it is that , if i use for-each loop, it says to use option -source 1.5, i used it, didnt work, so...
6
2275
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 like to delete one record in database, it always shows "record not found" in my program, even if the data has been deleted. I tried to used function...
1
1075
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
7700
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.