Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .gradle/7.4/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/7.4/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified .gradle/7.4/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified .gradle/7.4/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified .gradle/7.4/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified .gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
Binary file modified .gradle/file-system.probe
Binary file not shown.
9 changes: 9 additions & 0 deletions .idea/Fourth-Assignment-Steam-Scraper.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 19 additions & 11 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added build/classes/java/main/Game.class
Binary file not shown.
Binary file added build/classes/java/main/Parser.class
Binary file not shown.
Binary file added build/classes/java/test/ParserTest.class
Binary file not shown.
18 changes: 4 additions & 14 deletions build/reports/tests/test/classes/ParserTest.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>Class ParserTest</h1>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">3</div>
<div class="counter">1</div>
<p>tests</p>
</div>
</td>
Expand All @@ -41,7 +41,7 @@ <h1>Class ParserTest</h1>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.035s</div>
<div class="counter">0.016s</div>
<p>duration</p>
</div>
</td>
Expand Down Expand Up @@ -75,18 +75,8 @@ <h2>Tests</h2>
</tr>
</thead>
<tr>
<td class="success">testSortByArea()</td>
<td class="success">0.028s</td>
<td class="success">passed</td>
</tr>
<tr>
<td class="success">testSortByName()</td>
<td class="success">0.003s</td>
<td class="success">passed</td>
</tr>
<tr>
<td class="success">testSortByPopulation()</td>
<td class="success">0.004s</td>
<td class="success">0.016s</td>
<td class="success">passed</td>
</tr>
</table>
Expand All @@ -99,7 +89,7 @@ <h2>Tests</h2>
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 7.4</a> at Feb 28, 2024, 6:39:51 PM</p>
<a href="http://www.gradle.org">Gradle 7.4</a> at Apr 23, 2025, 8:09:18 PM</p>
</div>
</div>
</body>
Expand Down
14 changes: 7 additions & 7 deletions build/reports/tests/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1>Test Summary</h1>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">3</div>
<div class="counter">1</div>
<p>tests</p>
</div>
</td>
Expand All @@ -38,7 +38,7 @@ <h1>Test Summary</h1>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.035s</div>
<div class="counter">0.016s</div>
<p>duration</p>
</div>
</td>
Expand Down Expand Up @@ -82,10 +82,10 @@ <h2>Packages</h2>
<td class="success">
<a href="packages/default-package.html">default-package</a>
</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0.035s</td>
<td>0.016s</td>
<td class="success">100%</td>
</tr>
</tbody>
Expand All @@ -109,10 +109,10 @@ <h2>Classes</h2>
<td class="success">
<a href="classes/ParserTest.html">ParserTest</a>
</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0.035s</td>
<td>0.016s</td>
<td class="success">100%</td>
</tr>
</tbody>
Expand All @@ -126,7 +126,7 @@ <h2>Classes</h2>
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 7.4</a> at Feb 28, 2024, 6:39:51 PM</p>
<a href="http://www.gradle.org">Gradle 7.4</a> at Apr 23, 2025, 8:09:18 PM</p>
</div>
</div>
</body>
Expand Down
10 changes: 5 additions & 5 deletions build/reports/tests/test/packages/default-package.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>Default package</h1>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">3</div>
<div class="counter">1</div>
<p>tests</p>
</div>
</td>
Expand All @@ -40,7 +40,7 @@ <h1>Default package</h1>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.035s</div>
<div class="counter">0.016s</div>
<p>duration</p>
</div>
</td>
Expand Down Expand Up @@ -80,10 +80,10 @@ <h2>Classes</h2>
<td class="success">
<a href="../classes/ParserTest.html">ParserTest</a>
</td>
<td>3</td>
<td>1</td>
<td>0</td>
<td>0</td>
<td>0.035s</td>
<td>0.016s</td>
<td class="success">100%</td>
</tr>
</table>
Expand All @@ -96,7 +96,7 @@ <h2>Classes</h2>
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 7.4</a> at Feb 28, 2024, 6:39:51 PM</p>
<a href="http://www.gradle.org">Gradle 7.4</a> at Apr 23, 2025, 8:09:18 PM</p>
</div>
</div>
</body>
Expand Down
6 changes: 2 additions & 4 deletions build/test-results/test/TEST-ParserTest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="ParserTest" tests="3" skipped="0" failures="0" errors="0" timestamp="2024-02-28T15:09:51" hostname="DESKTOP-UC73C4L" time="0.037">
<testsuite name="ParserTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2025-04-23T16:39:18" hostname="DESKTOP-3BM3509" time="0.016">
<properties/>
<testcase name="testSortByArea()" classname="ParserTest" time="0.028"/>
<testcase name="testSortByName()" classname="ParserTest" time="0.003"/>
<testcase name="testSortByPopulation()" classname="ParserTest" time="0.004"/>
<testcase name="testSortByName()" classname="ParserTest" time="0.016"/>
<system-out><![CDATA[]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
Binary file modified build/test-results/test/binary/results.bin
Binary file not shown.
Binary file modified build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
Binary file modified build/tmp/compileTestJava/previous-compilation-data.bin
Binary file not shown.
14 changes: 7 additions & 7 deletions src/main/java/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ public class Game {
private int price;

public Game(String name, double rating, int price) {
//TODO

this.name = name;
this.rating = rating;
this.price = price;
}

public String getName() {
return name;
}


public double getRating() {
return rating;
}
Expand All @@ -25,16 +25,16 @@ public int getPrice() {

@Override
public String toString() {
//TODO
return "";
return name + " | Rating: " + rating + "/5 | Price: " + price + "€";
}

@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);
return Double.compare(game.rating, rating) == 0 &&
price == game.price &&
Objects.equals(name, game.name);
}

}
46 changes: 28 additions & 18 deletions src/main/java/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,51 @@

public class Parser {
static List<Game> games = new ArrayList<>();
String path = "C:\\Users\\mobin\\Desktop\\javaa\\work_shop\\Scrapper\\src\\main\\resources\\Games.html";

public List<Game> sortByName(){
public List<Game> sortByName() {
List<Game> sortedByName = new ArrayList<>(games);
// Sort games alphabetically (least)
//TODO
return sortedByName;
sortedByName.sort(Comparator.comparing(Game::getName));
return sortedByName;
}

public List<Game> sortByRating(){
public List<Game> sortByRating() {
List<Game> sortedByRating = new ArrayList<>(games);
// Sort games by rating (most)
//TODO
sortedByRating.sort(Comparator.comparingDouble(Game::getRating).reversed());
return sortedByRating;
}

public List<Game> sortByPrice(){
public List<Game> sortByPrice() {
List<Game> sortedByPrice = new ArrayList<>(games);
// Sort games by price (most)
//TODO
sortedByPrice.sort(Comparator.comparingInt(Game::getPrice).reversed());
return sortedByPrice;
}


public void setUp() throws IOException {

//Parse the HTML file using Jsoup
//TODO
Document doc = Jsoup.parse(new File(path), "UTF-8");
Elements gameElements = doc.select(".game");

// Extract data from the HTML
//TODO
for (Element game : gameElements) {
String name = game.select(".game-name").text();
double rating = Double.parseDouble(game.select(".game-rating").text().split("/")[0]);
int price = Integer.parseInt(game.select(".game-price").text().replace(" €", ""));
games.add(new Game(name, rating, price));
}

// Iterate through each Game div to extract Game data
//TODO
// for having exactly 100 games
if (games.size() > 100) {
games = games.subList(0, 100);
}
}

public static void main(String[] args) {
//you can test your code here before you run the unit tests
Parser parser = new Parser();
try {
parser.setUp();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}