-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNameRecord.java
68 lines (59 loc) · 1.5 KB
/
NameRecord.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
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.io.*;
import java.util.*;
/**
* Class to score each line into a name and an ArrayList record
*
* @author Dhruv Patel
* @version 12.15.2021
*/
public class NameRecord
{
// instance variables
private String name;
private ArrayList<Integer> arrayList;
/**
* Constructor for the NameRecord class
*/
public NameRecord(String line) {
arrayList = new ArrayList<Integer>();
String[] parsedData = line.split(" "); // splits between the name and the data
name = parsedData[0];
for (int i = 1; i < parsedData.length; i++) {
arrayList.add(Integer.parseInt(parsedData[i])); // creates an ArrayList of the data points
}
}
/**
* Gets the name of the inputted line
*
* @return name
*/
public String getName() {
return name;
}
/**
* Gets the data associated with the provided index
*
* @param index
* @return arrayList.get(index)
*/
public int getData(int index) {
return arrayList.get(index);
}
/**
* Sets the name provided a new name (through parameter)
*
* @param newName
*/
public void setName(String newName) {
this.name = newName;
}
/**
* Sets the data with a specific index and value in the arrayList
*
* @param index
* @param value
*/
public void setData(int index, int value) {
arrayList.set(index, value);
}
}