-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dataline.java
125 lines (112 loc) · 2.66 KB
/
Dataline.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import java.util.Arrays;
/**
* This object emulates a line of the input file.
*
* @author Michail - Panagiotis Bofos
*
*/
public class Dataline {
/**
* Each line of inputs in our case has the name of our molecule, its biological
* action and a vector its characteristics.
*/
private double stats[];
private String name;
private double goal;
/**
* Our constructor only needs the size of the characteristics vector.
*
* @param size Integer size of the characteristics vector
*/
public Dataline(int size) {
stats = new double[size];
}
/**
* This method alters a value in the characteristics vector.
*
* @param place Integer number of the characteristic we want to change
* @param value Double new value we want to add
*/
public void addStat(int place, double value) {
stats[place] = value;
}
/**
* This method alters a value in the characteristics vector.
*
* @param place Integer number of the characteristic we want to change
* @param value String new value we want to add
*/
public void addStat(int place, String value) {
addStat(place, Double.parseDouble(value));
}
/**
* This method returns the characteristic value of an input.
*
* @param place Integer number of the characteristic we want to get
* @return Double characteristic value
*/
public double getStat(int place) {
return stats[place];
}
/**
* This method changes the name of a molecule.
*
* @param value String new name
*/
public void setName(String value) {
name = new String(value);
}
/**
* This method returns the name of a molecule.
*
* @return String name of the molecule
*/
public String getName() {
return name;
}
/**
* This method sets the biological action wanted for a molecule.
*
* @param value Double biological action
*/
public void setGoal(double value) {
goal = value;
}
/**
* This method sets the biological action wanted for a molecule.
*
* @param value String biological action
*/
public void setGoal(String value) {
setGoal(Double.parseDouble(value));
}
/**
* This method returns the biological action of a molecule.
*
* @return Double biological action
*/
public double getGoal() {
return goal;
}
/**
* This method returns a String with the details of an input line.
*/
@Override
public String toString() {
return "Dataline name= " + name + " , goal = " + goal + " stats= " + Arrays.toString(stats);
}
/**
* This method prints all the info of an input line.
*/
public void print() {
System.out.println(toString());
}
/**
* This method returns a vector with all the characteristic of a molecule.
*
* @return
*/
public double[] getInputs() {
return stats;
}
}