这里是我的主题矩阵....现在我想使被摄物体矩阵没有插入所有组合?
mat pro
mat null null
pro null null
例如在数学科目上我受到programing
插入对象值semester =1
我把semester = 4
所以我想填补这之间的条件与“yes
”,只有在第一个主题的semester
比学期更大的第二个主题和矩阵“no
”如果不是......现在的问题,我是,我可以为组合输入的条件:
math - math , which would be "no"
math - programing , which would be "no"
programing - programing , which would be "no"
,这看起来像这样的程序完成时:
mat pro
mat no no
pro no no
,但我没有这样的组合要求把条件: 编程 - 数学,这将是“是” 它可能应该是这样的:
mat pro
mat no no
pro yes no
我该如何做到这一点?任何想法?
这里是我的代码:
public void makeGraph() {
matrix = new String[subjects.size()][subjects.size()];
for (int i = 0; i < matrix.length; i++) {
for (int j = i; j < matrix.length; j++) {
System.out.println("Enter conditionality between subjects: " + subjects.get(i).getName() + ", and "
+ subjects.get(j).getName());
boolean conditioned = s.nextBoolean();
if (conditioned == true) {
if (subjects.get(i).getSemester() > subjects.get(j).getSemester()) {
matrix[i][j] = "yes";
matrix[j][i] = "yes";
} else {
matrix[i][j] = "no";
matrix[j][i] = "no";
}
} else {
matrix[i][j] = "no";
matrix[j][i] = "no";
}
}
}
}
编辑:这里是引擎收录我已经解决了它的链接。 Solution
你的职位是这么写的不好,请作出努力.. – azro
@azro我很抱歉,我知道,但我不能让它,它试图正确写入它不起作用。 –
如果我的解决方案有帮助,请点击我答案旁边的灰色复选标记,接受它,让它变绿吗?此外,单击我的答案旁边的箭头将不胜感激:) – Assafs