last year
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import java.util.Objects;
|
||||
|
||||
public class Game {
|
||||
private String name;
|
||||
private double rating;
|
||||
private int price;
|
||||
|
||||
public Game(String name, double rating, int price) {
|
||||
//TODO
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public double getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
@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;
|
||||
Game game = (Game) o;
|
||||
return Double.compare(game.rating, rating) == 0 && Double.compare(game.price, price) == 0 && Objects.equals(name, game.name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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<Game> games = new ArrayList<>();
|
||||
|
||||
public List<Game> sortByName(){
|
||||
List<Game> sortedByName = new ArrayList<>(games);
|
||||
// Sort games alphabetically (least)
|
||||
//TODO
|
||||
return sortedByName;
|
||||
}
|
||||
|
||||
public List<Game> sortByRating(){
|
||||
List<Game> sortedByRating = new ArrayList<>(games);
|
||||
// Sort games by rating (most)
|
||||
//TODO
|
||||
return sortedByRating;
|
||||
}
|
||||
|
||||
public List<Game> sortByPrice(){
|
||||
List<Game> sortedByPrice = new ArrayList<>(games);
|
||||
// Sort games by price (most)
|
||||
//TODO
|
||||
return sortedByPrice;
|
||||
}
|
||||
|
||||
public void setUp() throws IOException {
|
||||
|
||||
//Parse the HTML file using Jsoup
|
||||
//TODO
|
||||
|
||||
// Extract data from the HTML
|
||||
//TODO
|
||||
|
||||
// Iterate through each Game div to extract Game 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