类之间的数组?

时间:2015-04-20 17:29:01

标签: java arraylist

主类;

package finalapp;
import java.util.Scanner;

/**
 *
 * @author bassammetwally
 */
public class FinalApp {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner input = new Scanner(System.in);
        Team tem = new Team();
        Tournament tour = new Tournament();
        System.out.print("Whats the tournament name?\n");
        tour.setTourName(input.next());
        System.out.print("Please enter the tournamen date\n");
        tour.setTourDate(input.next());
        System.out.print("Please enter the location\n");
        tour.setLocation(input.next());
        System.out.print("Please enter number of Software Stations\n");
        tour.setAvaliableHardwareIns(input.nextInt());
        System.out.print("Please enter number of Hardware Stations\n");
        tour.setAvaliableHardwareIns(input.nextInt());
        System.out.print("Please enter number of field testing");
        tour.setAvaliableFieldTesting(input.nextInt());
        System.out.print("Please enter max number of teams\n");
        tour.setMaxNumberOfTeams(input.nextInt());
        tour.tourStatSet(1);

        while (true)
        {
            int choice;
            choice = input.nextInt();
            if (choice == 1)
            {
                System.out.printf("Enter Team %s Names\n",tour.getMaxNumberOfTeams());
                for (int i = 0; i >= tour.getMaxNumberOfTeams();i++)
                {
                    System.out.print("Please Enter Team Name");
                    tour.addingTeam(input.next());
                    tem.teamStats(1);
                    tem.teamJudgeStat(1);
                    Have a PREPARING team turn the robot on 
                    (set the robot status to READY) to prepare for inspections        
                }
            }
            else if ( choice == 2)
            {
               System.out.print("Sending prepareing teams");
               //for (int a = 0; a >= tour.getTeamsChecked(); a++)
               {

               }

            }
    }


}

问题:

我正在进行机器人比赛模拟,我正在努力让主要课程:

  • 添加我已经完成的团队
  • 更改阵列中每个团队的状态

但我的主要想法是通过ArrayList并更改其他类中的变量,但我无法弄清楚如何去做。

有没有更简单的方法呢?

1 个答案:

答案 0 :(得分:0)

听起来你应该能够使用简单的getter和setter来做你想做的事。

只需要一个方法可以将所需的值设置为数组,另一个方法可以获取数组或数组中的特定索引。这样您就可以在类之间设置和共享数​​组。