Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Generic Class #2220

Open
ashishsme14 opened this issue May 25, 2021 · 1 comment
Open

Java Generic Class #2220

ashishsme14 opened this issue May 25, 2021 · 1 comment

Comments

@ashishsme14
Copy link

@ashishsme14 ashishsme14 commented May 25, 2021

We had followed code from

https://www.coursehero.com/u/file/90903507/java-genetxt/

java_gene.txt.pdf

Isuse Screen 1
Isuse Screen 2
Isuse Screen 3
Isuse Screen 4

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();
}
}
@raisahab9125
Copy link

@raisahab9125 raisahab9125 commented May 31, 2021

Ya sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants