java求救,在线等
1.Given the completed definition of the Course class above, complete the output produced
when the following section of code is executed:
Course c1 = new Course("CS", 101, 0, false);
System.out.println("1. " + c1.toString());
c1.setIsGenEd(true);
c1.setSemester(c1.getSemester() + 1);
System.out.println("2. " + c1.toString());
2.c) The program below contains the method printResult(). In the start() method make
one call to the printResult() method. Your call to the printResult() method must
compile.
public class MyProgram {
public void start() {
(3 marks)
}
private void printResult(int num, String letters,
boolean testType) {
String toLookFor = "" + num;
int position = letters.indexOf(toLookFor);
if (testType && position > -1) {
System.out.println("Correct!");
} else if (testType == false && position == -1) {
System.out.println("Correct!");
} else {
System.out.println("Not Correct!");
}
}
}
做完说明下原理,谢了