Java Video Tutorial 8

preview_player
Показать описание


I thought it would be fun to teach Java while I make a video game. This is a simple game, but it will teach a lot of the logic needed to make your own game.

This tutorial will teach you about arrays, class fields, class methods, how to set a default value for an array, and a ton of logic.
Рекомендации по теме
Комментарии
Автор

Feel free to skip parts 8 and 10. You won't miss anything. I was experimenting with an idea and I don't like the way those 2 videos came out. Feel free to ask questions

derekbanas
Автор

Feel free to skip parts 8 and 10. It was an experiment for the most part. As per how to use these videos, it is best to print out the code and take notes in your own words as you watch. Ask me any questions you have. In the end you'll have a personal api. Then experiment with the classes and functions covered. Eventually I start making real apps like a paint app, calculator, games, Android apps and more.

derekbanas
Автор

give this man a cookie! putting so much awesome work for free on the internet and still replaying to almost everyone to their questions, this is something rare. I appreciate you very much sir ! 

praf
Автор

Thank you very much :) The goal from creating these videos was and always will be to provide a free education to all. Soon I'll start covering math, chemistry, electronics and biology in a fun way.

derekbanas
Автор

Thank you very much :) I'm very happy to be here to help. Basically the MonsterTwo class is adding additional features that the Monster class didn't have. Other than that they are completely different from each other. In hindsight I think I used an example that was to complicated to early in the tutorial. It is probably best to skip over parts 8 and 10. You won't miss anything and I like the way the rest of the tutorial flows after this part. Feel free to ask questions

derekbanas
Автор

I'm glad you fixed it :) I'm very happy to help you guys whenever I can. Always feel free to ask questions

derekbanas
Автор

To tell it what what data type is in the array, then you tell it the variable name to store the data in from each index in the array. Then you give it the name of the array to cycle through. You could do this easily with a regular for loop but this is a nice shortcut

derekbanas
Автор

When I started learning to speed read I focused only on fiction books for quite some time. Then I moved on to nontechnical books for a while after that. It took me over 3 months of practice before I noticed any benefits from speed reading. Books filled with algorithms normally don't work well for me with speed reading

derekbanas
Автор

I wouldn't focus to much on this logic part of the tutorial. I was just experimenting with a new way of making tutorials. In part 9 I cover arrays completely and then continue with a more normal tutorial from parts 11 and on from there.

derekbanas
Автор

You're doing a fabulous job! I'm very happy to have been able to help. You definitely have an eye for making games. Anyone that can make a simple text based Russian Roulette game interesting is very talented :)

derekbanas
Автор

Thank you :) static is used when you want every class object to share just one field or method.So, that means if 1 object changes the value for a static field it will change for every other object as well. Does that make sense?

derekbanas
Автор

Yes I write programs for individuals. Mainly investing stuff. That is why I can't make the investing tutorials people keep asking for. Maybe some day?

That is a great idea to make a chess or checkers type game! The more you explore the language and dig up answers to questions the better you'll get. Make sure you keep all of this code organized and you'll be able to pull from it for things you may forget. The whole idea behind these tutorials is to cover everything so you can use it like a tool

derekbanas
Автор

The class is the blueprint for making objects. Main should actually do very little most of the time aside from creating the objects. Because I'm demonstrating just Java concepts here like for loops, input, output, if, while, etc. I tend to use main more to avoid complication. I hope that helps

derekbanas
Автор

Hello, You're very welcome :) I don't often get named along with Stanford, so thank you for that. You get the 2nd dimension arrays length with battleBoard[0].length. Sorry if I didn't say that. I was experimenting with part 8 and 10 and I don't like how those 2 parts came out so feel free to skip them. I think I did a much better job at explaining logic in java in my Object Oriented Design tutorial. I hope that helps

derekbanas
Автор

Yes it is in there. Inside of Eclipse make the Project Explorer display (Window - Show View - Project Explorer). Open the folder you are using in Eclipse for your code in the Project Explorer. There should be a folder named JRE System Library. If you open commons-lang3-3.1.jar and then org.apache.commons.lang3 you should see ArrayUtils.class Is that there? You should also have a lib folder and it should contain commons-lang3-3.1.jar

derekbanas
Автор

Do you want to know how to make a board that changes its size? You can't change the size of an Array after it has been made, but you can do that with ArrayLists. I cover them very soon in the tutorial. Don't worry to much about this part of the tutorial. It is just a review and some logic stuff. If everything doesn't make sense that is ok for just this part. Feel free to move on as the tutorial settles down in part 11 and on from there

derekbanas
Автор

The class is a blueprint for creating the objects. The objects then have their own version of the variables and functions defined by the class. Does that make sense?

derekbanas
Автор

It is used to reference a field that is in the class if an attribute is passed into a method with the same name. So, if you have a method named custName and a function setCustName(String custName) you would set the new value like this -> this.custName = custName

It is there to help you keep straight which field you mean to work with. Does that make sense?

derekbanas
Автор

You're very welcome :) I'm glad you are enjoying them. I must be crazy because I'm not sure what line of code you are referring to? Sorry about that I'm mobile right now

derekbanas
Автор

@SuggestiveSquirrels Thank you. I wasn't sure if I was changing things to quickly, or moving to fast. Tell me if I am. I like criticism.

derekbanas