package lab1.resources;
public class Pattern
{
private double[] features = null;
private int classIndex;
public Pattern(int p)
{
 features = new double[p];
}
public Pattern(Pattern x)
{
 features = new double[x.getCount()];
for (int i = 0; i < features.length; i++)
{
 features[i] = x.features[i];
}
this.classIndex = x.classIndex;
}
public final int getCount()
{
return features.length;
}
public final double getItem(int index)
{
if (0 <= index && index < features.length)
{
return features[index];
}
else
{
throw new IndexOutOfBoundsException(String.format("Invalid index %1$s in range %2$s:%3$s", index, 0, features.length - 1));
}
}
public final void setItem(int index, double value)
{
if (0 <= index && index < features.length)
{
features[index] = value;
}
else
{
   throw new IndexOutOfBoundsException(String.format("Invalid index %1$s in range%2$s:%3$s", index, 0, features.length - 1));
}
}
 public final int getClassIndex()
 {
return classIndex;
 }
 public final void setClassIndex(int value)
 {
 classIndex = value;
 }
 @Override
 public String toString()
 {
String text = "";
for (int i = 0; i < features.length; i++)
{

 text = String.format("%1$s{1:.00}%3$s", text, features[i], i == features.length - 1 ? "" : ",");
}
return text;
 }
}