Java 比较两种不同的数组列表

Java 比较两种不同的数组列表,java,methods,arraylist,constructor,Java,Methods,Arraylist,Constructor,这是我第一次使用stackFlow,我需要帮助 我是编程新手。 我有一个我创建的方法,它要求每一场比赛的得分和失分。我希望有人解释我需要做什么,仅此而已,或者如果不可能这样做的话 我想将团队的名称存储在arrayList中 我怎么才能问,什么是阿森纳积分榜,什么是阿森纳积分榜,什么是利物浦积分榜和利物浦积分榜?请,如果你不明白我的问题,让我知道,这样我可以更好地重新措辞。谢谢 public class projectscore { public int pointsMade; publi

这是我第一次使用stackFlow,我需要帮助 我是编程新手。 我有一个我创建的方法,它要求每一场比赛的得分和失分。我希望有人解释我需要做什么,仅此而已,或者如果不可能这样做的话 我想将团队的名称存储在arrayList中

我怎么才能问,什么是阿森纳积分榜,什么是阿森纳积分榜,什么是利物浦积分榜和利物浦积分榜?请,如果你不明白我的问题,让我知道,这样我可以更好地重新措辞。谢谢

public class projectscore
{
  public int pointsMade;
  public int pointsLost;
  public projectscore(int pointsM, int pointsL)
  {
   pointsMade = pointsM;`enter code here`
   pointsLost = pointsL;
  }

  public void setpointsMade(int pointsM)
  {
    pointsMade = pointsM;

  }
  public void setpointsLost(int pointsL)
  {

    pointsLost = pointsL;

  }
  public int getpointsMade()
  {
    return pointsMade;

  }
  public int getpointsLost()
  {

    return pointsLost;

  }
  public void getfinalScore()
  {

   System.out.println(pointsMade);
   System.out.println(pointsLost);
  }
}

import java.util.*;
public class fProjectScore
{
  public static void main(String[] args)
  {
    projectscore pscore = new projectscore(0, 0);
    Scanner in = new Scanner(System.in);


    System.out.println("what is the points made today ");
    Integer temp = in.nextInt();
    System.out.println("what is the points lost today ");
    Integer temp2 = in.nextInt();


    pscore.setpointsMade(temp);
    pscore.setpointsLost(temp2);

 /*   HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    map.put(temp, temp2);
   */ 
    if(temp > temp2)
    {
      System.out.println("winner"); 
    }
    else  if(temp < temp2)
    {
      System.out.println("losser"); 
    }
    else  if(temp == temp2)
    {
      System.out.println("Tie Game"); 
    }
}
}

i want to add this to my main method 
 ArrayList<String>participants = new ArrayList<String>();
participants.add("Arsenal");
participants.add("Liverpool);

how do i get it to ask, What is Arsenal pointsMade, What is Arsenal pointsLost, and What it liverpool pointsMade and pointsLost? please, if you dont understand my question, let me know so i can rephrase it better. Thanks.
公共类projectscore
{
公共int点模型;
公共int点SLOST;
公共项目分数(整数分SM、整数分SL)
{
pointsMade=pointsM;`在这里输入代码`
pointsLost=pointsL;
}
公共无效集合点模式(int pointsM)
{
pointsMade=pointsM;
}
公共无效设置点列表(int pointsL)
{
pointsLost=pointsL;
}
公共int getpointsMade()
{
返回点模型;
}
public int getpointsLost()
{
返回点时差;
}
public void getfinalScore()
{
System.out.println(PointsMode);
System.out.println(pointsLost);
}
}
导入java.util.*;
公共类fProjectScore
{
公共静态void main(字符串[]args)
{
projectscore pscore=新的projectscore(0,0);
扫描仪输入=新扫描仪(系统输入);
System.out.println(“今天的要点是什么”);
整数温度=in.nextInt();
System.out.println(“今天丢了多少分”);
整数temp2=in.nextInt();
pscore.setpointsMade(温度);
pscore.setpointsLost(temp2);
/*HashMap=newHashMap();
映射放置(临时,临时2);
*/ 
如果(温度>温度2)
{
System.out.println(“获胜者”);
}
否则如果(温度<温度2)
{
System.out.println(“losser”);
}
否则如果(临时==临时2)
{
System.out.println(“平局游戏”);
}
}
}
我想把它添加到我的主方法中
ArrayListparticipants=新的ArrayList();
参与者。添加(“阿森纳”);
加上(“利物浦”);
我该怎么问,什么是阿森纳积分榜,什么是阿森纳积分榜,什么是利物浦积分榜和利物浦积分榜?如果你不明白我的问题,请告诉我,这样我可以更好地重新措辞。谢谢。

我建议您仔细阅读面向对象编程,并为团队创建一个类

这里有一些伪代码。没有经过测试,但它应该能让你明白我的意思

public class Team {
    int points;
    final String name;

    public Team(String name) { this.name = name; }

    public void setPoints(int p) { this.points = p; }
    public int getPoints() { return this.points; }
    public String getName() { return this.name; }
}

void main() {
    Team arsenal = new Team("Arsenal");
    Team liverpool = new Team("Liverpool");
    ArrayList<Team> teams = new ArrayList<Team>();
    teams.add(arsenal);
    teams.add(liverpool);

    Scanner in = new Scanner(System.in);
    for(Team team : teams) {
        System.out.println("How many points did " + team.getName() + " made today");
        Integer points = in.nextInt();
        team.setScore(points);
    }

    // Sort the teams by score somehow
    teams.sort()

    // Get the winners 
    ArrayList<List> winners = this.getWinners(teams)

    if (winners.count > 1) {
        // It's a draw between the ones in the winners arraylist
    } else {
        println("The winner is: " + winners.get(0).name)
    }
}
公共类团队{
积分;
最后的字符串名;
公共团队(字符串名称){this.name=name;}
公共无效设定点(int p){this.points=p;}
public int getPoints(){返回this.points;}
公共字符串getName(){返回this.name;}
}
void main(){
阿森纳队=新球队(“阿森纳”);
利物浦队=新球队(“利物浦”);
ArrayList团队=新建ArrayList();
加上(阿森纳);
加上(利物浦);
扫描仪输入=新扫描仪(系统输入);
对于(团队:团队){
System.out.println(“今天”+team.getName()+“得了多少分”);
整数点=in.nextInt();
团队核心(分数);
}
//以某种方式按得分对球队进行排序
团队排序()
//赢家
ArrayList winners=this.getWinners(团队)
如果(winners.count>1){
//这是在优胜者名单中的一个平局
}否则{
println(“获胜者是:”+winners.get(0.name))
}
}

是的,我不明白,请再解释一下?我如何让方法看到arrayList参与者?我想使用arrayList中的元素询问“阿森纳制造”的要点是什么?阿森纳失去的要点是什么"? 因此,对于arrayList中的每个元素,我希望能够提出问题。英语不是我的第一语言,所以我很难深入解释。如果我在arraylist中有10个元素,我希望它为每一个元素提问。或者我是不是走错了方向?哦,我想你听说过Java API吧?您可以使用ArrayList上的查找方法,这里是链接。