samedi 28 mars 2015

Properties for Each Team in ArrayLists


Vote count:

0




so I have a class that contains Info for a Tournament. i have an arraylist that takes Team Names. i just need an idea or function that can let me load info from other classes ( Robots, TeamInfo) into every assigned member inside the ArrayLists.


Also any criticism that improves my coding is very accepted and appreciated


Test is the Main Class. Tournament is the class that contains the Tournament Info.



package test;
import java.util.Scanner;

/**
*
* @author
*/
public class Test {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String TheTournamentName, Date, Location;
int SoftwareStations , HardwareStations , FieldTesting;
Tournament UsingTheMain = new Tournament();
System.out.printf("Please Enter The Tournament Name\n");
TheTournamentName = input.nextLine();
UsingTheMain.setName(TheTournamentName);
//System.out.printf(UsingTheMain.getName());
System.out.printf("Please Enter the Date\n");
Date = input.nextLine();
UsingTheMain.setDate(Date);
System.out.printf("Please Enter The Location\n");
Location = input.nextLine();
UsingTheMain.setLocation(Location);
System.out.printf("Please Enter Number of Software Stations you want. Max Allowed is 2\n");
SoftwareStations = input.nextInt();
UsingTheMain.setSoftwareStations(SoftwareStations);
System.out.printf("Please Enter Number of Hardware Stations you want. Max allowed is 2\n");
HardwareStations = input.nextInt();
UsingTheMain.setHardwareStations(HardwareStations);
System.out.printf("Please Enter Number of Field Stations. Max Allowed is 2\n");
FieldTesting = input.nextInt();
UsingTheMain.setFieldTesting(FieldTesting);
System.out.printf("Please Enter 8 Teams");





// TODO code application logic here
}

}


Second class



import java.util.ArrayList;
import java.util.Scanner;

/**
*
* @author
*/
public class Tournament {
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author
*/
private String Name = "TournamentDEFULT";
private String Date = "22nd of Feb";
private String Location = "Texas";
private ArrayList<String> TeamNames = new ArrayList<String>();
private ArrayList<String> list = new ArrayList<String>();
private int HardwareStations = 2;
private int SoftwareStations = 2;
private int FieldTesting = 2;
Scanner input = new Scanner(System.in);

public String getName() {
return Name;
}

public void setName(String Name) {
//System.out.printf("Please Enter The Name Of The Tournament. It Could be a Number or Words but will be a String\n");
this.Name = Name;
}

public String getDate() {
return Date;
}

public void setDate(String Date) {
//System.out.printf("Please Enter the Date of The Tournament.\n");
this.Date = Date;
}

public ArrayList<String> getTeamNames() {
return TeamNames;
}

public void setTeamNames(int X) {
for (int i = 0; i >= X; i++)
{
int Q = 0;
String C;
System.out.printf("Please Enter the %n Team Names ;\n",Q);
C = input.nextLine();
TeamNames.add(C);
Q=1+Q;
}
}

public String getLocation() {
return Location;
}

public void setLocation(String Location) {
this.Location = Location;
}

public ArrayList<String> getList() {
return list;
}

public void setList(String X) {
list.add(X);
}

public int getHardwareStations() {
return HardwareStations;
}

public void setHardwareStations(int HardwareStations) {
this.HardwareStations = HardwareStations;
}

public int getSoftwareStations() {
return SoftwareStations;
}

public void setSoftwareStations(int SoftwareStations) {
this.SoftwareStations = SoftwareStations;
}

public int getFieldTesting() {
return FieldTesting;
}

public void setFieldTesting(int FieldTesting) {
this.FieldTesting = FieldTesting;
}




public Tournament()
{

}



}


asked 1 min ago







Properties for Each Team in ArrayLists

Aucun commentaire:

Enregistrer un commentaire