Created
February 25, 2016 08:28
-
-
Save golenishchev/6653e53527b7d93ab8da to your computer and use it in GitHub Desktop.
Anime Recommendation
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
package com.example.anime; | |
public class AnimeLibrary { | |
private String animeTitle; | |
private double score; | |
private String type; //movie | |
private int episodes; | |
private String genres; | |
private String rating; // age | |
public AnimeLibrary(String animeTitle, double score, String type, int episodes, String genres, String rating) { | |
this.animeTitle = animeTitle; | |
this.score = score; | |
this.type = type; | |
this.episodes = episodes; | |
this.genres = genres; | |
this.rating = rating; | |
} | |
@Override | |
public String toString() { | |
String result = "Title: "; | |
result += animeTitle + "\n"; | |
result += "Score: " + score + "\n"; | |
result += "Type: " + type + "\n"; | |
result += "Episodes: " + episodes + "\n"; | |
result += "Genres: " + genres + "\n"; | |
result += "Rating: " + rating + "\n"; | |
return result; | |
} | |
} |
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
package com.example.anime; | |
import java.util.ArrayList; | |
import java.util.Scanner; | |
public class Main { | |
private ArrayList<AnimeLibrary> animeList; | |
public static void main(String[] args) { | |
Main myMain = new Main(); | |
Recommendation myRecommendation = new Recommendation(); | |
myRecommendation.askHowMuchTitlesWatched(); | |
Scanner dataInput = new Scanner(System.in); | |
/** | |
* СДЕЛАТЬ ЧТОБЫ ДАННЫЕ ПЕРЕДАВАЛИСЬ В КАКОЙ НИБУДЬ ОБОБЩЁННЫЙ МЕТОД, | |
* А ОТТУДА ГЕТТЕРОМ БРАТЬ ДАННЫЕ В МЕТОД РЕКОМЕНДАЦИЙ. | |
* ЕСЛИ СООТВЕТСТВУЕТ КАКОМУ-ТО ОТВЕТУ, ТО ВЫВЕСТИ ДАННЫЕ В КОНСОЛЬ | |
*/ | |
myRecommendation.setTitlesCount(dataInput.nextInt()); | |
switch (myRecommendation.getTitlesCount()) { | |
case 1: | |
myRecommendation.getRandomRecomendation(); | |
break; | |
default: | |
System.out.println("You have a typo, try again"); | |
break; | |
} | |
myMain.animeList = new ArrayList<AnimeLibrary>(); | |
myMain.setArrayList(myMain.animeList); | |
myMain.animeList.add(new AnimeLibrary("Eve no Jikan (Movie)", 8.33, "Movie", 1, "Sci-Fi, Slice of Life", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Watashi ga Motenai no wa Dou Kangaetemo Omaera ga Warui!", 7.34, "TV", 12, | |
"Comedy, School, Shounen, Slice of Life", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Tokyo Godfathers", 8.34, "Movie", 1, "Comedy, Drama", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Shokugeki no Souma", 8.67, "TV", 24, "Ecchi, School, Shounen", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Sennen Joyuu", 8.35, "Movie", 1, | |
"Action, Adventure, Drama, Fantasy, Historical, Romance", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Perfect Blue", 8.18, "Movie", 1, "Dementia, Drama, Horror, Psychological", | |
"R+")); | |
myMain.animeList.add(new AnimeLibrary("Overlord", 8.10, "TV", 13, "Action, Adventure, Fantasy, Game, Supernatural", | |
"R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Shiki", 8.03, "TV", 22, "Mystery, Supernatural, Thriller, Vampire", "R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Lucky☆Star", 7.91, "TV", 24, "Comedy, Parody, School, Slice of Life", | |
"PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Kurau Phantom Memory", 7.49, "TV", 24, | |
"Action, Drama, Sci-Fi, Space, Super Power", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Kiseijuu: Sei no Kakuritsu", 8.63, "TV", 24, | |
"Action, Drama, Horror, Psychological, Sci-Fi, Seinen", "R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Jormungand", 7.98, "TV", 12, "Action, Adventure, Seinen", "R+")); | |
myMain.animeList.add(new AnimeLibrary("Hyouka", 8.19, "TV", 22, "Mystery, School, Slice of Life", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Hotaru no Haka", 8.59, "Movie", 1, " Drama, Historical", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Hellsing Ultimate", 8.63, "OVA", 10, | |
"Action, Horror, Military, Seinen, Supernatural, Vampire", " R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Gintama Movie: Kanketsu-hen - Yorozuya yo Eien Nare", 9.12, "Movie", 1, | |
"Gintama Movie: Kanketsu-hen - Yorozuya yo Eien Nare", "PG-13")); | |
myMain.animeList.add(new AnimeLibrary("Gankutsuou", 8.30, "TV", 24, "Drama, Mystery, Sci-Fi, Supernatural, Thriller", | |
"R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Detroit Metal City", 8.30, "OVA", 12, "Comedy, Music", "R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Dennou Coil", 8.21, "TV", 26, "Adventure, Comedy, Drama, Mystery, Sci-Fi", | |
"G - All Ages")); | |
myMain.animeList.add(new AnimeLibrary("Death Note", 8.75, "TV", 37, | |
"Mystery, Police, Psychological, Supernatural, Thriller", " R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("B Gata H Kei", 7.23, "TV", 12, "Comedy, Ecchi, Romance, School, Seinen", "R+")); | |
myMain.animeList.add(new AnimeLibrary("Code Geass: Hangyaku no Lelouch", 8.85, "TV", 25, | |
"Action, Mecha, Military, School, Sci-Fi, Super Power", "R - 17+")); | |
myMain.animeList.add(new AnimeLibrary("Azumanga Daioh", 8.09, "TV", 26, "Comedy, School, Slice of Life", "PG-13")); | |
/** | |
* Рекомендуем аниме | |
*/ | |
System.out.println("--- Recommended anime ---"); | |
// System.out.println(animeList.get((int) (Math.random() * animeList.size()))); // рандом от 1 до 23 | |
/** | |
* Добавить метод для получения количества элементов в коллекции. Это будет максимумом для рандома. | |
* Метод size() позволяет узнать количество объектов в коллекции. | |
*/ | |
System.out.println("всего аниме в базе: " + myMain.animeList.size()); | |
// myRecommendation.printIterator(animeList); | |
myRecommendation.giveAchivement(); // Outputs only in some cases | |
System.out.println("For More Details Press \"M\""); | |
myRecommendation.setTitlesCount(dataInput.nextInt()); | |
switch (myRecommendation.getTitlesCount()) { | |
case 1: | |
myRecommendation.getRandomRecomendation(); | |
break; | |
default: | |
System.out.println("You have a typo, try again"); | |
break; | |
} | |
} // END main | |
/** | |
* Геттер для доступа к данным ArrayList animeList | |
*/ | |
public ArrayList<AnimeLibrary> getAnimeList() { | |
return animeList; | |
} | |
public void setArrayList(ArrayList<AnimeLibrary> animeList) { | |
this.animeList = animeList; | |
} | |
} |
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
package com.example.anime; | |
import java.util.ArrayList; | |
import java.util.ListIterator; | |
public class Recommendation { | |
private int titlesCount; | |
private int randomRecommendation; | |
public void askHowMuchTitlesWatched() { | |
System.out.println("How many anime titles have you watched?"); | |
} | |
public int getTitlesCount() { | |
return titlesCount; | |
} | |
public void setTitlesCount(int titlesCount) { | |
this.titlesCount = titlesCount; | |
} | |
public void giveAchivement() { | |
if (titlesCount == 1) { | |
System.out.println("New Achivement: First step of Otaku"); | |
} else { | |
} | |
} | |
public int getRandomRecomendation(){ | |
Main myMain = new Main(); | |
System.out.println("тра-та-та " + myMain.getAnimeList().size()); | |
// randomRecommendation = (int) (Math.random() * myMain.getAnimeList.size()); | |
return randomRecommendation; | |
} | |
public void setRandomRecommendation(int randomRecommendation) { | |
this.randomRecommendation = randomRecommendation; | |
} | |
/* public void printIterator(ArrayList<AnimeLibrary> animeList) { | |
ListIterator<AnimeLibrary> animeIterator = animeList.listIterator(); | |
while (animeIterator.hasNext()) { | |
System.out.println(animeIterator.next()); | |
} | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment