Skip to content

Week4 #3

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

Merged
merged 25 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
20ef81d
Week3. Change the name of the class Rater.java to PlainRater.java and…
SkyrocketStan Jul 8, 2021
313d577
Week3. Assignment 1: Efficiency
SkyrocketStan Jul 8, 2021
eb0c4c0
Week3. Assignment 1: Efficiency
SkyrocketStan Jul 8, 2021
57e152d
Week3. Additional Starter Files for Assignment 2
SkyrocketStan Jul 8, 2021
fd56aa6
Week3. Create a new class named ThirdRatings.
SkyrocketStan Jul 8, 2021
e77c8a3
Week3. printAverageRatings(int minimalRatings)
SkyrocketStan Jul 9, 2021
fc579ef
Week3. printAverageRatingsByYear
SkyrocketStan Jul 11, 2021
29ec5b7
Week3. class GenreFilter
SkyrocketStan Jul 11, 2021
636a0a5
Week3. printAverageRatingsByGenre
SkyrocketStan Jul 11, 2021
b9af468
Week3. a new class named MinutesFilter
SkyrocketStan Jul 11, 2021
39fbaf5
Week3. printAverageRatingsByMinutes
SkyrocketStan Jul 11, 2021
448da71
Week3. a new class named DirectorsFilter
SkyrocketStan Jul 11, 2021
3f5ab18
Week3. DirectorsFilter
SkyrocketStan Jul 11, 2021
9e31a34
Week3. printAverageRatingsByYearAfterAndGenre
SkyrocketStan Jul 11, 2021
6746cae
Week3. printAverageRatingsByDirectorsAndMinutes
SkyrocketStan Jul 11, 2021
cdaa3cd
Week3. Congratulations! You passed!
SkyrocketStan Jul 11, 2021
76a8030
Week4. Additional files
SkyrocketStan Jul 11, 2021
eea3556
Week4. Create a new project and copy over your classes from the last …
SkyrocketStan Jul 11, 2021
e5d121c
Week4. getAverageByID
SkyrocketStan Jul 11, 2021
cd3c6b9
Week4. getAverageRatingsByFilter
SkyrocketStan Jul 11, 2021
5d7f9e2
Week4. dotProduct + mass refactoring
SkyrocketStan Jul 11, 2021
12a6ad1
Week4. getSimilarities
SkyrocketStan Jul 11, 2021
10a6bc6
Week4. remove unused
SkyrocketStan Jul 11, 2021
395636c
Week4. Done
SkyrocketStan Jul 12, 2021
d2b2efa
Merge branch 'main' into Week4
Jul 12, 2021
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
1 change: 1 addition & 0 deletions .idea/modules.xml

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

33 changes: 33 additions & 0 deletions Week4/Week4.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../apache-csv.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../apache-csv.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library" exported="">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../courserajava.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../courserajava.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>
24 changes: 24 additions & 0 deletions Week4/src/AllFilters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import java.util.ArrayList;

public class AllFilters implements Filter {
ArrayList<Filter> filters;

public AllFilters() {
filters = new ArrayList<>();
}

public void addFilter(Filter f) {
filters.add(f);
}

@Override
public boolean satisfies(String id) {
for (Filter f : filters) {
if (!f.satisfies(id)) {
return false;
}
}

return true;
}
}
25 changes: 25 additions & 0 deletions Week4/src/DirectorsFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* A class for filter movies by directors
*
* @author Stanislav Rakitov
* @version 1.0
*/
public class DirectorsFilter implements Filter {
String directors;

public DirectorsFilter(String directors) {
this.directors = directors;
}

@Override
public boolean satisfies(String id) {
String movieDirectors = MovieDatabase.getDirector(id);
String[] filterDirectors = directors.split(",");
for (String direcor : filterDirectors) {
if (movieDirectors.contains(direcor)) {
return true;
}
}
return false;
}
}
51 changes: 51 additions & 0 deletions Week4/src/EfficientRater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import java.util.ArrayList;
import java.util.HashMap;

/**
* The class EfficientRater keeps track of one rater and all their ratings.
*
* @author Stanislav Rakitov
* @version 1.0
*/
public class EfficientRater implements Rater {
private final String myID;
private final HashMap<String, Rating> myRatings;

public EfficientRater(String id) {
myID = id;
myRatings = new HashMap<>();
}

public void addRating(String movieID, double rating) {
myRatings.put(movieID, new Rating(movieID, rating));
}

public boolean hasRating(String movieID) {
return myRatings.containsKey(movieID);
}

public String getID() {
return myID;
}

public double getRating(String movieID) {
Rating rating = myRatings.get(movieID);
if (rating != null) {
return rating.getValue();
} else {
return -1;
}
}

public int numRatings() {
return myRatings.size();
}

public ArrayList<String> getItemsRated() {
return new ArrayList<>(myRatings.keySet());
}

public HashMap<String, Rating> getMyRatings() {
return myRatings;
}
}
3 changes: 3 additions & 0 deletions Week4/src/Filter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public interface Filter {
boolean satisfies(String id);
}
Loading