HW5
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import java.util.Objects;
|
||||
|
||||
public class Movie {
|
||||
private String title;
|
||||
private double rating;
|
||||
private int year;
|
||||
|
||||
public Movie(String title, double rating, int year) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public double getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
//TODO
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Movie movie = (Movie) o;
|
||||
return Double.compare(movie.rating, rating) == 0 && movie.year == year && Objects.equals(title, movie.title);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class Parser {
|
||||
static List<Movie> movies = new ArrayList<>();
|
||||
|
||||
public List<Movie> sortByTitle() {
|
||||
List<Movie> sortedByTitle = new ArrayList<>(movies);
|
||||
// Sort movies alphabetically by title
|
||||
//TODO
|
||||
return sortedByTitle;
|
||||
}
|
||||
|
||||
public List<Movie> sortByRating() {
|
||||
List<Movie> sortedByRating = new ArrayList<>(movies);
|
||||
// Sort movies by rating (highest to lowest)
|
||||
//TODO
|
||||
return sortedByRating;
|
||||
}
|
||||
|
||||
public List<Movie> sortByYear() {
|
||||
List<Movie> sortedByYear = new ArrayList<>(movies);
|
||||
// Sort movies by year (newest to oldest)
|
||||
//TODO
|
||||
return sortedByYear;
|
||||
}
|
||||
|
||||
public void setUp() throws IOException {
|
||||
// Parse the HTML file using Jsoup
|
||||
//TODO
|
||||
|
||||
// Extract data from the HTML
|
||||
//TODO
|
||||
|
||||
// Iterate through each movie div to extract movie data
|
||||
//TODO
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// You can test your code here before you run the unit tests
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user