Hi everyone,
We've got some awesome contributions in our last coding challenge.
First of all, like promised my solution of the challenge:
https://pastebin.com/7QcxjVpu
But your contributions are at least as good!
But now, let's get to the point.
This next coding challenge is all about objects.
Objects?
Yes, Object-oriented programming has become one of the most successful programming paradigms because of the ease to map real-world problems to code.
Since you've shown in the previous challenge that you know your way around loops, switch-case, random numbers and reading or writing from and to the console, I feel we're ready for this.
The next coding challenges will build upon each other to have our first little project to show off to our friends, family, dogs or cats, so stay tuned.
You can show it to your goldfish as well (Please don't wake up your Hamster yet)
The task will be the following:
You will create one class called "Movie"
This class will have several variables:
Title (String), Overview(String), Genre (String[]), release-date(String) + any other info you would like.
After you created this class I want you to create several objects of this class
That means, you will create instances of your "Movie" filling the variables you previously defined.
In order to fill those movies let the user at the console define the number of movies he wants to create and then let him type the data in the console.
Following this you will store all those movies in a List/Set/Map/Array and print them out to console.
Hint: create a .toString method in your movie class
Don't feel down! Start coding!
If you have any questions or problems just write it into the comments so I can help you!
My Solution : https://ideone.com/n4XOYi
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Looking perfectly fine =)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
nice post ;)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @raycoms! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of upvotes received
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Here is my entry.
https://pastebin.com/vQaYJxpU
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
The above code is not working out the way i thought it would. I am going to leave it though and see if I can get the issue figured out. it is in my if/else statements, I know that. just not sure what to do about it yet.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
So, I have spent the last few hours redoing the code (I am still new to Programming) and basically had to change all of it.
Now I keep getting a null pointer exception, where just a bit ago, I wasn't. Right when the user needs to hit a number 1-4 to choose the genre of the movie.
Before this, it ran fine until I asked the user if they would like to enter another movie. That throws an exception about a missing element. I am putting the code up.
https://pastebin.com/w1qQY5aM
Please take a look and help me to understand what happened.
I put comments in the code regarding the issue.
Thank You,
Gene @btcworker
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hi @btcworker, the issue is that:
Is not initialized you have to do:
Additionally, I would create the class "Movie" in a separate file and call it from another file with the main class.
This is not only important for readability but will also help us to extend the program later on.
Keep on coding!
P.S: I had to remove the > and the < tags because steemit doesn't like them =)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Besides that your variables in the movie should not be static
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks for the help on it. The only reason I didn't create it in a separate file/class was because i thought it was supposed to be one file.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I also already posted my solution in the next challenge or if you need any more help, just ask =)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit