d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > So I Need Some Help
Add Reply New Topic New Poll
Member
Posts: 18,791
Joined: Dec 13 2011
Gold: Locked
Warn: 20%
Mar 7 2014 06:47pm
My girlfriend is working on a project at school, using Visual basic.

This is what she needs to do.

She has a list of movie genres (about 45) She needs movies attactched to each genre, some movies will have multiple genres
She will then have a survey it will ask what type of genres the person likes and based on those it will suggest movies for the person to watch. The survey is in a one question form with many check able boxes


Whats the best way to go about this?
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Mar 7 2014 08:27pm
Make a movie class that has a title field as string and genre field as an string array/list then spawn a list of this class with the details about each movie filled out.

Else a simple hash array would work.

Code
class Movies
def initialize
@movies = []
end

def addMovie(title, genres)
movie_hash = {'title' => title, 'genres' => genres}
@movies.push movie_hash
end

def removeMovie(title)
@movies.each_with_index do |hash, index|
if hash['title'].eql? title
@movies.delete_at index
break;
end
end
end

def getMovieGenres(title)
@movies.each_with_index do |hash, index|
if hash['title'].eql? title
if hash['genres'].kind_of?(Array)
return hash['genres'].join(' ')
else
return hash['genres']
end
end
end
end

def toString()
result = ''
@movies.each do |hash|
result += hash['title'] + ' '
end
return result
end
end

movieList = Movies.new()

movieList.addMovie('movie1', ['horror', 'suspsense'])
movieList.addMovie('movie2', 'thriller')
movieList.addMovie('movie3', ['action', 'thriller', 'suspense'])

puts movieList.toString()
puts movieList.getMovieGenres('movie1')
puts movieList.getMovieGenres('movie2')
movieList.removeMovie('movie2')
puts movieList.toString()


Code
ruby movies.rb
Process started >>>
movie1 movie2 movie3
horror suspsense
thriller
movie1 movie3
<<< Process finished. (Exit code 0)


How this applies to your project is up to you to interpret.

This post was edited by AbDuCt on Mar 7 2014 08:31pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll