forked from jomokojomoko/ICS-PROJECT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Type.java
55 lines (49 loc) · 1.6 KB
/
Type.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.io.*;
public class Type{
// Class which holds essentially the possible starting stats for the player
private Stats[] stats;
private String[] names;
private int[] id;
// Accesors and mutators
public Stats[] getStats(){
return stats;
}
public void setStats(Stats[] stats1){
stats=stats1;
}
public String[] getNames(){
return names;
}
public void setNames(String[] names1){
names=names1;
}
public int[] getId(){
return id;
}
public void setId(int[] ids){
id=ids;
}
// Constructor
public Type(){
try{
BufferedReader in=new BufferedReader(new FileReader("Type.txt"));
stats=new Stats[Integer.parseInt(in.readLine())];
names=new String[stats.length];
id=new int[stats.length];
//Reads in the names Id and Stats from a text file.
for(int i=0;i<stats.length;i++){
names[i]=in.readLine();
id[i]=Integer.parseInt(in.readLine());
stats[i]=new Stats(Integer.parseInt(in.readLine()),Integer.parseInt(in.readLine()),Integer.parseInt(in.readLine()),Integer.parseInt(in.readLine()),Integer.parseInt(in.readLine()),(int)(Math.random()*10)+1,Integer.parseInt(in.readLine()),Integer.parseInt(in.readLine()));
}
in.close();
}
catch(IOException iox){
System.out.println("Error in reading file.");
}
}
// Selection of the specific type
public Stats choose(int identity) {
return stats[identity-1];
}
}