-
-
public class Test {
-
-
public static void main (String [] arg) {
-
// "012345678910" alignment guide
-
String [] results = {"AR 4 BR 5",
-
"CR 0 DR 1",
-
"AR 10 CR 9",
-
"BR 3 DR 1",
-
"AR 0 DR 2",
-
"BR 2 AR 2",
-
"BR 0 CR 5",
-
"CR 1 BR 3",
-
"CR 4 AR 2",
-
"DR 1 AR 1",
-
"DR 2 BR 1",
-
"DR 0 CR 2",
-
-
"ES 2 FO 2",
-
"GR 0 HE 0",
-
"FO 1 GR 2",
-
"HE 3 ES 5",
-
"ES 4 GR 3",
-
"ES 0 HE 2",
-
"GR 1 FO 3",
-
"GR 2 ES 1",
-
"FO 2 HE 1",
-
"FO 3 ES 3",
-
"HE 1 FO 0",
-
"HE 2 GR 1"};
-
-
-
-
League myLeague = new League();
-
myLeague.setupDiv1();
-
myLeague.setupDiv2();
-
for(String r: results){
-
myLeague.addResult(r);
-
}// end for each r
-
-
myLeague.print();
-
//myLeague.testFindTeam("DR");
-
-
-
} //end method main ()
-
-
-
-
}// end class Test
-
-
-
-
import java.util.Vector;
-
import java.util.Collections;
-
-
public class League {
-
-
Vector<Team> teams;
-
-
String [] list1 = {"AR Arad", "BR Braila", "CR Craiova", "DR Drobeta"};
-
String [] list2 = {"ES Escandov", "FO Foscani", "GR Gronstadt", "HE Hermansburg"};
-
-
public League() {
-
teams = new Vector<Team>();
-
}// end constructor League()
-
-
public void setupDiv1 () {
-
for (int i=0; i<list1.length; i++) {
-
String code = list1[i].substring(0,2);
-
String name = list1[i].substring(3);
-
addTeam(1, code, name);
-
} //end for i
-
}// end method setupDiv1 ()
-
-
-
public void setupDiv2 () {
-
for (int i=0; i<list2.length; i++) {
-
String code = list2[i].substring(0,2);
-
String name = list2[i].substring(3);
-
addTeam(2, code, name);
-
} //end for i
-
}// end method setupDiv2 ()
-
-
-
public void addTeam (int division, String code, String name) {
-
Team aTeam = new Team(division, code, name);
-
teams.add(aTeam);
-
}// end method addTeam()
-
-
public Team findTeam(String code) {
-
Team aTeam = null;
-
for (int i=0; i<teams.size(); i++) {
-
aTeam = teams.get(i);
-
if (aTeam.code.equals (code))break;
-
}// end for i
-
return aTeam;
-
}//end method findTeam()
-
-
public void testFindTeam(String code) {
-
Team aTeam = findTeam(code);
-
System.out.println("Found Team = "+aTeam.name);
-
}//end method findTeam()
-
-
-
public void addResult(String results){
-
String hCode = "AR";
-
String aCode = "BR";
-
int hScore = 4;
-
int aScore = 5;
-
-
Team homeTeam = this.findTeam(hCode);
-
homeTeam.addHomeResult(hScore,aScore);
-
-
Team awayTeam = this.findTeam(aCode);
-
awayTeam.addAwayResult(hScore,aScore);
-
}//end method addResult()
-
-
public void print() {
-
for (Team aTeam: teams) {
-
aTeam.print();
-
}// end forall teams
-
}// end method print()
-
-
}// end class League
-
-
-
-
import java.util.Collections;
-
import java.util.Comparator;
-
-
public class Team implements Comparable <Team> {
-
-
int division;
-
String name;
-
String code;
-
int points;
-
int played;
-
int scored;
-
int conceded;
-
int difference;
-
-
public int compareTo(Team aTeam){
-
-
return 0;
-
}//end method compareTo()
-
-
public Team(int division, String code, String name) {
-
this.division = division;
-
this.code = code;
-
this.name = name;
-
}// end constructor Team(code, name)
-
-
public void addResult(int home, int away) {
-
// home and away are goals score by home and away teams in a match
-
}// end method addResult()
-
-
public void addHomeResult(int home, int away) {
-
if (home==away) points = points + 1; // Draw
-
if (home > away) points = points + 2; // Home Win
-
//if (home < away) points = points + 3; // Away Win
-
played++;
-
scored = scored + home;
-
conceded = conceded + away;
-
difference = scored - conceded;
-
}// end method addHomeResult()
-
-
public void addAwayResult(int home, int away) {
-
if (home==away) points = points + 1; // Draw
-
//if (home > away) points = points + 2; // Home Win
-
if (home < away) points = points + 3; // Away Win
-
played++;
-
scored = scored + home;
-
conceded = conceded + away;
-
difference = scored - conceded;
-
}// end method addAwayResult()
-
-
public void print() {
-
System.out.println("DIV"+"\t"+"CODE"+"\t"+"POINTS"+"\t"+"PLAYED"+"\t"+"SCORED"+"\t"+"CONC"+"\t"+"DIFF");
-
System.out.println(division+"\t"+code+"\t"+points+"\t"+played+"\t"+scored+"\t"+conceded+"\t"+difference+"\t");
-
} //end method print()
-
-
}// end class Team
-
-
I have three classes: Test, League and Team
My program needs to display the champions of each division (1 and 2)
Display the names of the two teams that are being promoted/relegated.
I am having problems adding each result and then letting the program update the statistics for each team.
Can someone please helpppppppppppppppppp???
Thankyou.
2 17864 Dököll 2,364
Recognized Expert Top Contributor
Hopefully this is not homework, but thanks for posting your code...
I would say search here for answers on how to add variables and make available a result.
You could do something like this: -
//Return the total payment
-
public double getFinalPayment() {
-
double totalPayment;
-
totalPayment = weeklyPay() + comissionPayment() + overtimePayment();
-
return totalPayment;
-
}
-
-
Good luck with the project!
JosAH 11,448
Recognized Expert MVP @Dököll
That reply and the code snippet have nothing to do with the OP's problem. Please don't confuse people.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Domestos |
last post by:
Hi all,
Does anybody know of a fantasy football application written in php/mysql I
could purchase and run a league with?
Thanks
Andrew Makinson
|
by: abcd |
last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual
vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a
ljetvedehg, hard slog," mariyu vede legai pressed...
|
by: BrainKr |
last post by:
Still have 4 openings in our CBS SportsLine.com Fantasy Football league.
Champ wins $200
prize.
If interested, go to: http://football.sportsline.com/splash/football
Register for the GOLD...
|
by: edwgib2002 |
last post by:
Does anyone have any information related to a scheduling algorithm that
can be written in VBA and used in an access database to create balanced
team schedules for a league?
|
by: rupert |
last post by:
It seems a need a paradime shift in understanding how C++ use
libraries. Sun keeps is together under their API. And Javadoc enables a
neat way of displaying functions of a local program to display...
|
by: steve.falzon |
last post by:
Hi Folks
The new footy season is almost with us, in England anyway :)
I've just created a public league on the Times **FREE** fantasy
football league game so if anyone wants to join up please...
|
by: sugard |
last post by:
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...
|
by: Nirav Amin |
last post by:
Create a 2-D array containing the data :
Pakistan Sweden France Iran China
Japan Russia China Italy China
China ...
|
by: Ben Bacarisse |
last post by:
Bert <albert.xtheunknown0@gmail.comwrites:
<snip>
Do you have an example of a "slow" data set. Obviously I can make my
own, but such puzzles often come with data sets. I have a simple...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: 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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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,...
|
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...
|
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...
|
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 ...
| |