Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with this error I'm getting in Line 164 - (case 1) . It's saying no suitable method found for sort(List ) I

I need help with this error I'm getting in Line 164 - (case 1) . It's saying no suitable method found for sort(List) I provided the code below. ----- JAVA PROGRAMMINGimage text in transcribed . It's saying no suitable method found for sort(List) I provided the code below.

package comparator;

import comparator.Course; import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

import java.util.Scanner;

public class CourseDirectory {

/**

* @param args the command line arguments

*/

static List courses = new ArrayList();

public static void main(String[] args) {

CourseDirectory myDirectory = new CourseDirectory();

myDirectory.createFIUCourses();

myDirectory.displayMenu();

}

public void createFIUCourses()

{

//Create a loop that will ask user if he/she wants to create another course - do while //Inside loop, ask for all the information for a course //Create another loop inside the outer loop (nested loop) for prerequisites (while) //After the nested loop, create a Course object //Add Course object to arrayList of courses

// use scanner keyboard Scanner keyboard = new Scanner(System.in);

do

{ // Use do while loop and ask user for curse name, FLA course, year level, numbers of creds // store into variable

System.out.print("Enter your fiu course name: ");

String FIUCourseName = keyboard.next();

System.out.print("enter FLA course: ");

String FLACourseName = keyboard.next();

System.out.print("enter the year level: ");

int yearLevel = keyboard.nextInt();

System.out.print("enter the number of credits: ");

int numCredits = keyboard.nextInt();

ArrayList PreReqs = new ArrayList();

while(true)

{

System.out.print("Enter a pre-requisite for the course!! Press Q to stop !): ");

String preReq = keyboard.next();

if(preReq.equalsIgnoreCase("q")) break;

PreReqs.add(preReq);

}

Course course = new Course(FIUCourseName, FLACourseName, yearLevel, numCredits, PreReqs);

courses.add(course);

System.out.print("Press Q to stop entering courses or any other key to continue entering: ");

String userInput = keyboard.next();

if(userInput.equalsIgnoreCase("q")) break;

}while(true);

}

public void displayMenu()

{

//Create a loop that displays the menu of options:

//1. Sort courses by FIU course name

//2. Sort courses by FLA course name

//3. Sort courses by year level

//4. Exit

//Keep looping until the user enters option 4

//For each of the options 1- 3, call a specific method

Scanner keyboard = new Scanner(System.in);

while(true)

{

System.out.println("1. Sort courses by FIU course name");

System.out.println("2. Sort courses by FLA course name");

System.out.println("3. Sort courses by year level");

System.out.println("4. Exit");

int ForTheUser = keyboard.nextInt();

ComparatorByFLACourse comparatorByFLACourse = new ComparatorByFLACourse();

ComparatorByYearLevel comparatorByYearLevel = new ComparatorByYearLevel();

switch(ForTheUser)

{ case 1: Collections.sort(courses); System.out.println(courses); break ;

case 2: Collections.sort(courses, comparatorByFLACourse); System.out.println(courses); break;

case 3: Collections.sort(courses, comparatorByYearLevel); System.out.println(courses); break;

case 4: return;

}

}

}

X Comparator - NetBeans IDE 8.2 File Edit View Navigate Source Refactor Run Debug Profile Team Tools Window Help 90 T3DB0- - Search (Ctrl+I) Q # Course Directory.java x Projects ComparatorByFLACourse.java x ComparatorByYearLevel.java x Course.java x Source History E - 9 PB O W- 150 System.out.println("3. Sort courses by year level"); System.out.println("4. Exit"); int ForTheUser = keyboard.nextInt(); ComparatorByFLAcourse comparatorByFLACourse = new ComparatorByFLACourse(); ComparatorByYearLevel comparatorByYearLevel = new ComparatorByYearLevel(); switch (ForTheUser) case 1: Collections. sort (courses)System.out.println (courses); break; case 2: Collections. sort(courses, comparatorByFLACourse); System.out.println(courses); break; case 3: Collections. sort(courses, comparatorByYearLevel); System.out.println(courses); break; case 4: return; | 181 Output 167:5 INS 8:26 PM 1 Type here to search A D x 2/19/2020 a

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago