Solving TCS IPA Java Question. (Class Player)
Solving TCS IPA Java Question. (Class Player)
Question:
id - int
country - String
side - String
price - double
This method will take a String parameter along with the other parameter
as
array of Player objects. The method will return array of Player where the
search).
This method should be called from main method and display the id of
use Scanner object to read values for four Player objects referring the
Next call the method searchPlayerForMatch, write the logic to sort the id
---------------------------------------------------------------------
Input:
India
Batting
2500000
Australia
Batting
1000000
Srilanka
Bowling
1700000
England
Bowling
2000000
Batting
Output:
-------------------------------------------------------------------------
code:
import java.util.Scanner;
import java.util.Arrays;
int a=sc.nextInt();sc.nextLine();
String b=sc.nextLine();
String c=sc.nextLine();
double d=sc.nextDouble();sc.nextLine();
}
String input=sc.nextLine();
System.out.println(ans[i].id);
if(players[i].side.equalsIgnoreCase(input))
help=Arrays.copyOf(help,help.length+1);
help[help.length-1]=players[i];
//bubble sort
Player temp=help[j];
help[j]=help[j+1];
help[j+1]=temp;
if(help.length>0)
return help;
return null;
class Player
int id ;
String country;
String side;
double price;
//parametrized constructor
public Player(int id, String country, String side, double price) {
this.id = id;
this.country = country;
this.side = side;
this.price = price;
return id;
this.id = id;
return country;
this.country = country;
this.side = side;
return price;
this.price = price;