Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can someone provide solution for the following instructions?  RSS feed

 
Xiyu Zen
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Create a public class Movie with private instance variables String title and int year. The class should declare that it implements the Comparable interface, and should provide the following:

• A constructor that takes 2 arguments: a String and an int (in that order)
for initializing title and year.

• A method that satisfies the Comparable interface. Movies should be compared first by title and then by year.

{ The Maltese Falcon 1941, The Thomas Crown Affair 1968, The Thomas Crown Affair 1999}

An equals() method that is compatible with the method that satisfies the Comparable interface.

• A toString() method that prints “Movie” followed by 1 space followed by
the title followed by 1 space followed by open-parenthesis followed by
the year followed by close-parenthesis.
Example: The Maltese Falcon (1941)

• A public static method getTestMovies(), which returns an array of 10
unique Movie instances.
The 0th and 1st array elements must be 2 movies with the same title but from different years
(e.g. The Thomas Crown Affair 1968 and The Thomas Crown Affair 1999, or True Grit 1969 and True Grit 2010).
The 2nd and 3rd elements must 2 movies with different titles but from the same year
(e.g. The Martian 2015 and Bridge of Spies 2015).
The 4th and 5th elements must be 2 different objects that represent the same movie.

Create an interface called FilmArchive that defines 2 methods:
• getSorted(), which takes no args and returns ArrayList<Movie>.
• add(), which takes one arg of type Movie and returns a boolean. If add()
is called where the arg already appears in the film archive, the method
should return false and otherwise do nothing; if the arg of add() does not
yet appear in the archive, it should be added as described below and the
method should return true

 
Tim Moores
Saloon Keeper
Posts: 3882
91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sounds like homework you're supposed to be doing in order to learn something. So: what do you have so far? If you haven't started, what ideas have you had?
 
Liutauras Vilda
Marshal
Posts: 4626
316
BSD
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Cast Zen

Read this (<- link) article. In one or another way, understanding the content written in that article could be a crucial in your future career.
My advice is to read it carefully, once you done, you can start with an article Where Do I Start?

Don't try to solve everything in one go. Concentrate on the first sentence in your post at the moment only, it tells you clearly what needs to be done at first. Once you get that, post it here, so we can discuss it and the guys could give you some insights.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!