-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ProsperousRF/Week4
Week4
- Loading branch information
Showing
21 changed files
with
1,265 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public interface Filter { | ||
boolean satisfies(String id); | ||
} |
Oops, something went wrong.