Untitled
unknown
java
a year ago
1.1 kB
10
Indexable
public class LinearSystemResult {
private SolutionType solutionType;
private double[] solution;
private double[][] parametricForm; /
// Konstruktor buat result biasa
public LinearSystemResult(SolutionType solutionType, double[] solution) {
this.solutionType = solutionType;
this.solution = solution;
this.parametricForm = null;
}
// Konstruktor buat parametrik
public LinearSystemResult(SolutionType solutionType, double[][] parametricForm) {
this.solutionType = solutionType;
this.solution = null;
this.parametricForm = parametricForm;
}
// Cara user akses jawabannya tinggal .getSolution
public Object getSolution() {
if (solutionType == SolutionType.UNIQUE) {
return solution;
} else if (solutionType == SolutionType.PARAMETRIC) {
return parametricForm;
} else {
return null;
}
}
// getter buat tipe solusi (klo butuh)
public SolutionType getSolutionType() {
return solutionType;
}
}Editor is loading...
Leave a Comment