Advertisement
uriahheep

Untitled

Apr 3rd, 2020
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class FlightDatabase {
  4.     ArrayList<Flight> flights = new ArrayList<Flight> ();
  5.  
  6.     public FlightDatabase ( ) {
  7.         this.flights.add ( new Flight ( "Wroclaw", "Berlin" ) );
  8.         this.flights.add ( new Flight ( "Warsaw", "Poznan" ) );
  9.         this.flights.add ( new Flight ( "Krakow", "Vienna" ) );
  10.         this.flights.add ( new Flight ( "Wroclaw", "Rotterdam" ) );
  11.         this.flights.add ( new Flight ( "Warsaw", "Moscow" ) );
  12.         this.flights.add ( new Flight ( "Wroclaw", "Frankfurt" ) );
  13.         this.flights.add ( new Flight ( "Warsaw", "London" ) );
  14.         this.flights.add ( new Flight ( "Krakow", "Paris" ) );
  15.     }
  16.  
  17.     public void checkIfFlightExists ( ) {
  18.  
  19.         for (int i = 0; i < this.flights.size (); i++) {
  20.             Flight connection = flights.get ( i );
  21.             if (this.flights.equals ( connection ){
  22.                 System.out.println ("There is such connection");
  23.                
  24.             }
  25.  
  26.  
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement