Uploaded by Roba ahmed

code2

advertisement
package javaapplicationll;
import java.util.*;
class BASKETBALL {
String player_name;
String nickname;
int number;
String team_name;
String position;
int scored_points;
int rebounds;
int assists;
BASKETBALL(String player_name, String nickname, int number, String team_name, String position, int scored_points, int rebounds, int assists) {
this.player_name = player_name;
this.nickname = nickname;
this.number = number;
this.team_name = team_name;
this.position = position;
this.scored_points = scored_points;
this.rebounds = rebounds;
this.assists = assists;
}
}
class HANDBALL{
String player_name;
String nickname;
int number;
String team_name;
String position;
int goals_made;
int goals_received;
HANDBALL(String player_name , String nickname , int number , String team_name , String position , int goals_made , int goals_received){
this.player_name =player_name;
this.nickname = nickname;
this.number=number;
this.team_name=team_name;
this.position=position;
this.goals_made=goals_made;
this.goals_received=goals_received;
}
}
public class Main {
public static void main(String[] args) {
System.out.println("BASKETBALL");
int MVP ;
int max ;
String PN = null;
String TN = null;
int num[] = new int[5];
max = num[0];
BASKETBALL []a = new BASKETBALL[6];
a[0]=new BASKETBALL("Player 1","nick1",4, "Team A", "G",10,2,7);
a[1]=new BASKETBALL("Player 2","nick2",8, "Team A", "F",0,10,0);
a[2]=new BASKETBALL("Player 3","nick3",15, "Team A", "C",15,10,4);
a[3]=new BASKETBALL("Player 4","nick4",16, "Team B", "G",20,0,0);
a[4]=new BASKETBALL("Player 5","nick5",23, "Team B", "F",4,7,7);
a[5]=new BASKETBALL("Player 6","nick6",42, "Team B", "C",8,10,0);
for(BASKETBALL x : a) {
System.out.println(x.player_name + ";" + x.nickname + ";" + x.number + ";" + x.team_name + ";" + x.position + ";" + x.scored_points + ";" + x.rebounds + ";" + x.assists);
MVP = x.scored_points * 10 + x.rebounds* 5 + x.assists*0 ;
for (int i = 0; i < num.length; i++) {
num[i] = MVP;
if (num[i] >= max ) {
max = num[i];
PN=x.player_name;
TN= x.team_name;
}}
}
System.out.println("Most Valuable Player (MVP) = " + max + " \nwinning player is " +" [ ' " + PN + " ' ]" + "\nwinning player is " +" [ ' " + TN + " ' ]" ) ;
System.out.println("---------------------------------------------------");
System.out.println("HANDBALL");
HANDBALL []b = new HANDBALL[6];
b[0]=new HANDBALL("Player 1","nick1",4, "Team A", "G",0,20);
b[1]=new HANDBALL("Player 2","nick2",8, "Team A", "F",15,20);
b[2]=new HANDBALL("Player 3","nick3",15, "Team A", "F",10,20);
b[3]=new HANDBALL("Player 4","nick4",16, "Team B", "G",1,25);
b[4]=new HANDBALL("Player 5","nick5",23, "Team B", "F",12,25);
b[5]=new HANDBALL("Player 6","nick6",42, "Team B", "F",8,25);
for(HANDBALL x : b ) {
System.out.println(x.player_name + ";" + x.nickname + ";" + x.number + ";" + x.team_name + ";" + x.position + ";" + x.goals_made+ ";" + x.goals_received );
MVP = x.goals_made * 1 + x.goals_received *10;
for (int i = 0; i < num.length; i++) {
num[i] = MVP;
if (num[i] >= max ) {
max = num[i];
PN=x.player_name;
TN= x.team_name;
}}}
System.out.println("Most Valuable Player (MVP) = " + max + " \nwinning player is " +" [ ' " + PN + " ' ]" + "\nwinning player is " +" [ ' " + TN + " ' ]" ) ;
System.out.println("---------------------------------------------------");
}}
Download