You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Application.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import java.util.ArrayList;
  2. public class Application {
  3. public static void main( String[] args ) {
  4. Application app = new Application();
  5. app.init();
  6. app.run();
  7. app.done();
  8. }
  9. public void init() {
  10. System.out.println( "initializing application" );
  11. movies.add( new Movie("Regular_Movie_1 ", Movie.REGULAR ) );
  12. movies.add( new Movie("Regular_Movie_2 ", Movie.REGULAR ) );
  13. movies.add( new Movie("Children_Movie_1 ", Movie.CHILDRENS ) );
  14. movies.add( new Movie("Children_Movie_2 ", Movie.CHILDRENS ) );
  15. movies.add( new Movie("NewRelease_Movie_1", Movie.NEW_RELEASE ) );
  16. movies.add( new Movie("NewRelease_Movie_2", Movie.NEW_RELEASE ) );
  17. customers.add( new Customer( "Customer_A" ) );
  18. customers.add( new Customer( "Customer_B" ) );
  19. customers.add( new Customer( "Customer_C" ) );
  20. }
  21. public void run() {
  22. System.out.println( "application is running" );
  23. Customer customer_1 = customers.get( 0 );
  24. customer_1.addRental( new Rental( movies.get( 0 ), 2 ) );
  25. customer_1.addRental( new Rental( movies.get( 1 ), 3 ) );
  26. customer_1.addRental( new Rental( movies.get( 2 ), 3 ) );
  27. customer_1.addRental( new Rental( movies.get( 3 ), 4 ) );
  28. customer_1.addRental( new Rental( movies.get( 4 ), 3 ) );
  29. customer_1.addRental( new Rental( movies.get( 5 ), 4 ) );
  30. String statement = customer_1.statement();
  31. System.out.println( statement );
  32. System.out.println( customer_1.htmlStatement() );
  33. }
  34. public void done() {
  35. System.out.println( "application finished" );
  36. }
  37. private final ArrayList<Movie> movies = new ArrayList<>();
  38. private final ArrayList<Customer> customers = new ArrayList<>();
  39. }