-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Closed
Labels
Description
We had followed code from
https://www.coursehero.com/u/file/90903507/java-genetxt/
But there is an compilation error -
user@workspacejzgt8djbcdjuoa5m:/projects/challenge$ cd StudentGenericClass; mvn compile test; cat target/surefire-reports/*.xml
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Generics For Student 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ StudentGenericClass ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /projects/challenge/StudentGenericClass/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ StudentGenericClass ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 3 source files to /projects/challenge/StudentGenericClass/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/ScoreList.java:[17,37] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentList.java:[29,24] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[18,33] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,12] ')' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,20] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,14] variable declaration not allowed here
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[30,103] not a statement
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,1] illegal start of expression
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,43] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,45] not a statement
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,51] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[35,9] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[35,48] ')' expected
[INFO] 13 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.975 s
[INFO] Finished at: 2021-05-25T02:17:44+00:00
[INFO] Final Memory: 21M/784M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project StudentGenericClass: Compilation failure: Compilation failure:
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/ScoreList.java:[17,37] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentList.java:[29,24] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[18,33] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,12] ')' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,20] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[28,14] variable declaration not allowed here
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[30,103] not a statement
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,1] illegal start of expression
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,43] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,45] not a statement
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[32,51] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[35,9] ';' expected
[ERROR] /projects/challenge/StudentGenericClass/src/main/java/com/fresco/StudentClass.java:[35,48] ')' expected
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
cat: 'target/surefire-reports/*.xml': No such file or directory
Student Class code is
package com.fresco;
import java.text.DecimalFormat;
public class StudentClass {
public String getQuery(String studentData,String query){
DecimalFormat df = new DecimalFormat("#.00");
switch(query.charat(0)){
case '1':
String firstChar = query.split(",")[1];
String[] students = studentData.split(" ");
StudentList<String> studentList = new studentList<String>();
for (String student : students){
studentList.addElement(student);
}
return studentList.beginsWith(firstChar);
case '2':
String[] bloodGroups = query.split(",")[1].split(" ");
String reqBloodGroup = query.split(",")[2];
StudentList<String> studentData.split(" ");
String[] students2 = studentData.split(" ");
for(String student: students2){
studentList2.addElement(student);
}
return studentList2.bloodGroupOf(bloodGroups, reqBloodGroup);
case '3':
String threshold = query.split(",")[1];
StudentList<Integer>scoreList = new StudentList<>();
String[] score = studentData.aplit(" ");
if ( score: scores){
reList.addElement(Integer.parseInt(score));
String.valueOf(scoreList.thresholdScore(Integer.parseInt(threshold)))+ "students scored " + threshold+ "above";
st<Double> scoreList = new List<>();
] gpaArr = studentData.split(" "); ing gpa: gpaArr)
{
s.addElement(Double.parseDouble(gpa));s
string.valueOf(df.format(gpas.averageValue());
}
}
}
return null;
}
}
Score list code is -
package com.fresco;
import java.text.DecimalFormat;
import java.util.ArrayList;
public class ScoreList<T> {
ArrayList<T> arrayList = new ArraryList<>();
public void addElement(T element){
arrayList.add(element);
}
public void removeElement(T element){
arrayList.remove(element);
}
public T getElements(int index){
return arrayList.get(index);
}
public double averageValues(){
double total =0;
for(int i =0 ; i < arrayList.get(i));
{
total +=((Double)arrayList.get(i));
}
return total/arrayList.size();
}
}