public boolean removeFilm(String filmName) { int index = 0; for (Film film : films) { if (film.getFilmName().equals(filmName)) { films.remove(index); return true; } index++; } return false; }
public int preventitoTot() { int tot = 0; for (Film film : films) { tot += film.getSupporto().preventivo(); } return tot; }
public static Actor example4() { // include in populate Film film = new Film(); film.setName("Scream 4"); film.setDescription("Scream 3 was the last one! What's going on?"); film.setDuration(new java.math.BigDecimal(2)); Actor actor = new Actor(); actor.setId(4); actor.setFName("Nev"); actor.setLName("Campbell"); film.addActor(actor); return actor; }
public void supprimerPersonne(String nom) throws Exception { try { // Si la personne n'existe pas if (!personne.existe(nom)) { throw new Tp5Exception("Impossible de supprimer, la personne " + nom + " n'existe pas."); } // S'il est le realisateur d'au moins un film if (!film.filmDeRealisateur(nom).isEmpty()) { throw new Tp5Exception( "Impossible de supprimer, la personne " + nom + " a realise au moins un film."); } // S'il est le realisateur d'au moins une serie if (!serie.serieDeRealisateur(nom).isEmpty()) { throw new Tp5Exception( "Impossible de supprimer, la personne " + nom + " a realise au moins une serie."); } // S'il a un role dans au moins un film if (!roleFilm.rolesDeActeur(nom).isEmpty()) { throw new Tp5Exception( "Impossible de supprimer, la personne " + nom + " a un role dans au moins un film."); } // S'il a au moins un role dans au moins un episode d'au moins une serie if (!roleEpisode.rolesDeActeur(nom).isEmpty()) { throw new Tp5Exception( "Impossible de supprimer, la personne " + nom + " a un role dans au moins une series."); } int nb = personne.enlever(nom); cx.commit(); System.out.println(nb + " personne supprime."); } catch (Exception e) { cx.rollback(); throw e; } }
public static Actor findActorInFilm(Collection<Film> films, String film, String actorName) { Film foundedFilm = Film.findFilmInCollection(films, film); Iterator<Actor> itActor = foundedFilm.getActors().iterator(); Actor foundedActor = new Actor(); while (itActor.hasNext()) { Actor a = itActor.next(); if (actorName.equals(a.getActorName())) { foundedActor = a; System.out.println("I found this actor"); } else { System.out.println("I didn't find this actor"); } } return foundedActor; }
/** * Take the String representing the complete forecast in JSON Format and pull out the data we * need to construct the Strings needed for the wireframes. * * <p>Fortunately parsing is easy: constructor takes the JSON string and converts it into an * Object hierarchy for us. */ private List<Film> getUrlsFromJson(String urlsJsonStr) throws JSONException { // These are the names of the JSON objects that need to be extracted. final String RESULTS = "results"; final String POSTER_URL = "poster_path"; final String IMAGE_URL_BASE = "http://image.tmdb.org/t/p/w185/"; List<Film> urls = new ArrayList<>(); JSONObject urlsJson = new JSONObject(urlsJsonStr); JSONArray resultsArray = urlsJson.getJSONArray(RESULTS); for (int i = 0; i < resultsArray.length(); i++) { final JSONObject result = resultsArray.getJSONObject(i); Film film = new Film(); film.posterUrl = IMAGE_URL_BASE + result.getString(POSTER_URL); film.backdropUrl = IMAGE_URL_BASE + result.getString("backdrop_path"); film.originalTitle = result.getString("original_title"); film.overview = result.getString("overview"); film.releaseDate = result.getString("release_date"); film.voteAverage = result.getString("vote_average"); urls.add(film); } return urls; }
@Override public void onBackPressed() { Intent intent; intent = new Intent(getApplicationContext(), FilmListActivity.class); String pkg = getPackageName(); Category cat = new Category( film.getCategory(), 0); // 0 è un valore inutile serve solo per creare l'oggetto poichè utilizzeremo solo il // nome della categoria cat.setMultiplier(multiplier); intent.putExtra(pkg + ".myCategory", cat); // invio dati compreso moltiplicatore startActivity(intent); finish(); }
public GestionPersonne( Personne personne, Film film, RoleFilm roleFilm, Serie serie, RoleEpisode roleEpisode) throws Tp5Exception { this.cx = personne.getConnexion(); if (cx != film.getConnexion() || cx != serie.getConnexion() || cx != roleFilm.getConnexion() || cx != roleEpisode.getConnexion()) { throw new Tp5Exception("Les instances de connexions dans GestionPersonne sont différentes"); } this.personne = personne; this.film = film; this.serie = serie; this.roleFilm = roleFilm; this.roleEpisode = roleEpisode; }
private void updateFilm() { DbAdapterFilm dbHelper; dbHelper = new DbAdapterFilm(getApplicationContext()); dbHelper.open(); dbHelper.updateContact( film.getId(), film.getTitle(), film.getCategory(), film.getPoint(), film.getImage(), film.getNameImage(), film.getTitle()); dbHelper.close(); }
public static void main(String[] args) { ArrayList<Film> catalogue = new ArrayList<Film>(); System.out.println("Ajouter Le Parrain au Catalogue"); Film leParrain = new Film("Le parrain", "Francis Ford Coppola"); catalogue.add(leParrain); leParrain.nouvelleCritique("Roger Ebert", "Bla bla bla", 4); System.out.println("Ajouter Fargo au Catalogue"); Film fargo = new Film("Fargo", "Coens"); catalogue.add(fargo); fargo.nouvelleCritique("Alex cp", "Bla bla bla", 4); fargo.nouvelleCritique("Jonh Doe", "Bla bla bla", 3); fargo.nouvelleCritique("Jonh Doe", "Bla bla bla", 3); fargo.nouvelleCritique("Jonh Doe", "Bla bla bla", 5); // La moyenne des score de Fargo System.out.println(fargo.score()); }
public static TestSuite getInsertObjectTestSuite() { TestSuite suite = new TestSuite(); suite.setName("InserfaceWithoutTablesInsertObjectTestSuite"); suite.setDescription( "This suite tests the insertion of each object in the interface model (without tables)."); suite.addTest(new InsertObjectTest(Film.example2())); suite.addTest(new InsertObjectTest(Secretary.example2())); suite.addTest(new InsertObjectTest(Company.example3())); suite.addTest(new InsertObjectTest(CourseDeveloper.example1())); suite.addTest(new InsertObjectTest(Email.example2())); // suite.addTest(new InsertObjectTest(Employee.example3())); Cannot use insert test on emp as // bi-1-1 suite.addTest(new InsertObjectTest(PersonnelManager.example1())); suite.addTest(new InsertObjectTest(Phone.example1())); suite.addTest(new InsertObjectTest(ProductDeveloper.example3())); suite.addTest(new InsertObjectTest(ProductManager.example1())); suite.addTest(new InsertObjectTest(Receptionist.example1())); return suite; }
private Alias generateAliasFor(Film content) { return PaHelper.getFilmAlias(content.getId().toString()); }
/* Das Speichern der verwalteten Filme geschied beim Drücken der Butten * Gesehen, Merken, Favorit im Bereich der Detailansicht * * die toString-Methoder der Klasse wird schon auf andere Weise genutzt, * deswegen wird jeder Film über ein String-Array zu einem String gewandelt * Trennzeichen zwischen den Attributen => ; * Trennzeichen zwischen den Filmen => \n * */ public static void speichern() { String alle_verwalteten_filme = ""; String[] film_als_String = new String[23]; // Liste in String wandeln for (Film film : Film.get_verwaltete_filme()) { if (film != null) { film_als_String[0] = film.get_o_titel(); film_als_String[1] = film.get_o_jahr(); film_als_String[2] = film.get_o_rated(); film_als_String[3] = film.get_o_erschienen_am(); film_als_String[4] = film.get_o_laufzeit(); film_als_String[5] = film.get_o_genre(); film_als_String[6] = film.get_o_regisseur(); film_als_String[7] = film.get_o_schriftsteller(); film_als_String[8] = film.get_o_schauspieler(); film_als_String[9] = film.get_o_kurzbeschreibung(); film_als_String[10] = film.get_o_sprachen(); film_als_String[11] = film.get_o_land(); film_als_String[12] = film.get_o_auszeichnungen(); film_als_String[13] = film.get_o_adresse_vom_plakat(); film_als_String[14] = film.get_o_metascore(); film_als_String[15] = film.get_o_imdb_bewertung(); film_als_String[16] = film.get_o_imdb_stimmen(); film_als_String[17] = film.get_o_imdb_id(); film_als_String[18] = film.get_o_art(); film_als_String[19] = "" + film.iso_gesehen(); film_als_String[20] = "" + film.iso_gemerkt(); film_als_String[21] = "" + film.iso_favorit(); film_als_String[22] = film.get_o_bemerkung(); for (int i = 0; i < film_als_String.length; i++) { alle_verwalteten_filme = alle_verwalteten_filme + film_als_String[i] + ";"; } // Strings zusammenführen alle_verwalteten_filme = alle_verwalteten_filme + "\n"; } } // film-string speichern try { in_datei_schreiben(k_filmspeicher, alle_verwalteten_filme); } catch (Exception e) { fehler_ausgeben(e.getMessage()); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cover); Intent intent = getIntent(); // l'intent di questa activity Log.d("FilmActivity", "Intent intent=getIntent();"); String pkg = getPackageName(); film = (Film) intent.getSerializableExtra(pkg + ".myFilm"); multiplier = film.getMultiplier(); // prendo moltiplicatore ImageView imageFilm = (ImageView) findViewById(R.id.cover); Log.d("lista film", "prendo il film selezionato"); String uri = "drawable/" + film.getNameImage(); Log.d("lista film", "contenuto uri: " + uri); int imageResource = getResources().getIdentifier(uri, "drawable", getPackageName()); Log.d( "lista film", "imageResource: " + imageResource + " numero immagine:" + film.getNameImage()); Drawable image = getResources().getDrawable(imageResource); Log.d("lista film", "contenuto Drawable image: " + image); imageFilm.setImageDrawable(image); Button conferma = (Button) findViewById(R.id.conferma); conferma.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { EditText titolo = (EditText) findViewById(R.id.title); if (titolo.getText().toString().equalsIgnoreCase(film.getTitle())) { // salva sul bd updateUser(film.getPoint() * multiplier); updateFilm(); creaToast("Point +" + (film.getPoint() * multiplier)); if (aiutato = true) multiplier++; else multiplier = 1; /* try { Thread.sleep(5000); } catch (InterruptedException e) {e.printStackTrace();} */ String pkg = getPackageName(); Intent intent = new Intent(getApplicationContext(), FilmListActivity.class); Category cat = new Category( film.getCategory(), 0); // 0 è un valore inutile serve solo per creare l'oggetto poichè // utilizzeremo solo il nome della categoria cat.setMultiplier(multiplier); intent.putExtra(pkg + ".myCategory", cat); // invio dati compreso moltiplicatore startActivity(intent); finish(); } else { // messaggio di avviso creaToast("Hai Sbagliato"); multiplier = 1; aiutato = false; } } }); Button aiuto = (Button) findViewById(R.id.help); aiuto.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int na = film.getTitle().length() / 3; Log.d("AIUTO", "na=" + na); Log.d("AIUTO", "numhelp=" + numhelp); if (numhelp < 2) { numhelp++; Log.d("AIUTO", "numhelp=" + numhelp); help = help + film.getTitle().substring(help.length(), help.length() + na); Log.d( "AIUTO", "caratteri da aggiungere " + film.getTitle().substring(help.length(), help.length() + na)); Log.d("AIUTO", "help=" + help); EditText titolo = (EditText) findViewById(R.id.title); titolo.setText(help); int p; if (numhelp == 1) p = -10; else p = -35; aiutato = false; Log.d("AIUTO", "punti persi=" + p); updateUser(p); np = np + p; Log.d("AIUTO", "punti persi in totale=" + np); creaToast(p + "Point"); multiplier = 1; } else { creaToast("Non posso più aiutarti"); } } }); Button soluzione = (Button) findViewById(R.id.solution); soluzione.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { EditText titolo = (EditText) findViewById(R.id.title); titolo.setText(film.getTitle()); int p = -100; aiutato = false; updateUser(p); creaToast("point " + p); } }); }
public static void delActor(Collection<Film> films, String film, Actor actor) { Film foundedFilm = Film.findFilmInCollection(films, film); // foundedFilm.getActors().remove(foundedActor); foundedFilm.getActors().remove(actor); }
public void printFilms() { for (Film film : films) { film.printFilm(); } }