Kilobolt
  • Home
  • Tutorials
    • Game Development Tutorial >
      • Unit 1: Beginning Java >
        • Before you begin...
        • Day 1: Setting Up
        • Day 2: Java Basics
        • Day 3: More Basics
        • Day 4: Java Math
        • Day 5: More Math
        • Day 6: If... else...
        • Day 7: More Control Flow
        • Day 8: Looping
        • Day 9: More on Looping
        • Day 10: Inheritance, Interface
        • Day 11: Threads and Graphics
      • Unit 2: Creating a Game I >
        • Day 1: Foundations
        • Day 2: Basic Framework
        • Day 3: Taking User Input
        • Day 4: Enter the Robot
        • Day 5: Background and Sprites
        • Day 6: Adding Enemies
        • Day 7: Shooting Bullets
        • Day 8: Animations
        • Day 9: 2D-Arrays
        • Day 10: Painting the Tilemap
      • Unit 3: Creating a Game II >
        • Day 1: Level Creation - Part 1
        • Day 2: Level Creation - Part 2
        • Day 3: Level Creation - Part 3
        • Collision Detection Basics
        • Day 4: Collision Detection Part 1
        • Day 5: Collision Detection Part 2
        • Day 6: Collision Detection Part 3
        • Day 7: Health System & Death
        • Day 8: Basic AI & Final Touches
      • Unit 4: Android Game Development >
        • Day 1: Introduction to Android
        • Day 2: Setting up for Development
        • Day 3: Creating our First Android Application
        • Day 4: Parts of an Android Application
        • Day 5: The Android Game Framework: Part I
        • Day 6: The Android Game Framework: Part II
        • Create an Android Game From Scratch (or port your existing game)
        • Day 7: Creating an Android Game (From Start to Finish)
      • Reference Sheet
    • Zombie Bird Tutorial (Flappy Bird Remake) >
      • Unit 1: Building the Game >
        • Introduction
        • Day 1: Flappy Bird - An In-depth Analysis
        • Day 2: Setting up libGDX
        • Day 3: Understanding the libGDX Framework
        • Day 4: GameWorld and GameRenderer and the Orthographic Camera
        • Day 5: The Flight of the Dead - Adding the Bird
        • Day 6: Adding Graphics - Welcome to the Necropolis
        • Day 7: The Grass, the Bird and the Skull Pipe
        • Day 8: Collision Detection and Sound Effects
        • Day 9: Finishing Gameplay and Basic UI
        • Day 10: GameStates and High Score
        • Day 11: Supporting iOS/Android + SplashScreen, Menus and Tweening
        • Day 12: Completed UI & Source Code
    • Android Application Development Tutorial >
      • Unit 1: Writing Basic Android Apps >
        • Before you begin...
        • Day 1: Android 101
        • Day 2: Getting to Know the Android Project
        • Day 3: The Development Machine
        • Day 4: Building a Music App - Part 1: Building Blocks
        • Day 5: Building a Music App - Part 2: Intents
        • Day 6: Building a Music App - Part 3: Activity Lifecycles
  • New Forum
  • About Us
    • Contact Us
  • Our Games
    • TUMBL: FallDown
  • Facebook
  • Twitter

GAME DEVELOPMENT TUTORIAL: DAy 1-7: More Ctrl. Flow

9/16/2012

44 Comments

 
Picture
Lesson #1-12: Analysis of the BySimpleIMeanSimple class

Looking at yesterday's "game" in-depth.

Yesterday, we created our very first game. Now we will dissect the class behind it.

Here's the code: 
 import java.util.Random;

//The greatest game ever made follows.
class BySimpleIMeanSimple {


static int dieValue;

public static void main(String[] args) {

rollDie();

} // ends main


static void rollDie() {

Random rand = new Random();

// Assign a random number between 1 and 6 as dieValue
dieValue = rand.nextInt(6) + 1;

System.out.println("You rolled a " + dieValue);

// Why add 1? Think about it.
testDieValue(dieValue);

} // ends rollDie()


static void testDieValue(int dieValue) {

if (dieValue <= 2) {
System.out.println("You Lose.");
} // ends if

else if (dieValue == 3 || dieValue == 4 || dieValue == 5) {
System.out.println();
System.out.println("Rerolling.");
System.out.println();
rollDie();
} // ends else if

else if (dieValue == 6) {
System.out.println("You win! Congratulations!");
} // ends else if

} // ends testDieValue()

} // ends BySimpleIMeanSimple Class
1. The first line is simple: import the Random class.
2. We then declare the name of the class: BySimpleIMeanSimple
3. Then a static integer called dieValue, which will hold the value of the rolled die is created 
4. Next, we create the main method, which just invokes a method called rollDie();

5. The rollDie() method is then created. It has the following parts.

I. Creation of the Random object called rand.
II. Assignment of a random number between 0 and 5 (+1 since numbers range from 1 to 6 on a die) to the dieValue integer we created earlier.
III. It uses System.out.println to display the value of the integer dieValue.
IV. It invokes the method testDieValue(), which is defined below the rollDie() method. This testDieValue() method requires an integer parameter, so we input the new dieValue, which contains the random number between 1 and 6.

6. Next we declare the testDieValue() method. This is where the Control Flow statements happen (we control the way that the program proceeds based on conditional statements).
It takes the value of integer dieValue and then carries out the appropriate if statement.

I. If the value is less than or equal to 2, the player loses, so it displays, "You lose."
II. If the value is exactly 6 (==), it displays "You Win! Congratulations!"
III. If the value is 3 or 4 or 5 (This could've been written in many ways, such as: if (dieValue >= 3 && dieValue <= 5)...), it rerolls, invoking again the rollDie() method, which creates a random number and assigns it as the value of dieValue and then uses this value to invoke the testDieValue();

Someone asked earlier, what is the purpose of the: System.out.println();
Well, it is there to create an empty line in the console (where the output is displayed). It helps organize the way the program "speaks" to you.

NOTE: Make sure you are keeping up with the braces. When you do actually programming, braces won't be color coded to show you where the boundaries of each class or method are!

Lesson #1-13: Switches in Java

Java, much like railroad tracks, incorporates switches to direct the path of execution.
We will look at switches using an example that we have used before: a coin toss.

NOTE: Make sure that the class name in the Package Explorer to the left side of the screen on Eclipse matches that of the one stated in the code. Otherwise, you will get an error. The reason for this is that when you press Play, Eclipse looks for the class that with the name of the file that you are executing, and it will not be able to locate it.

(i.e. You should create a class named CoinTossSwitch.java and copy this code): 
 import java.util.Random;

class CoinTossSwitch {

public static void main(String[] args) {

Random rand = new Random();
int randomInt = rand.nextInt(2);

System.out.println(randomInt);

switch(randomInt) {

case 0:
System.out.println("Tails!");
break;
case 1:
System.out.println("Heads!");
break;

} // Ends switch

} // Ends main

} // Ends Class
Let's examine the switch in detail:
 switch (randomInt) {

case 0:
System.out.println("Tails!");
break;
case 1:
System.out.println("Heads!");
break;

} // Ends switch
As you can tell, the format of a switch is as follows  :
 switch (variable){

case 1: // if variable == 1
doThis();
break;

case 2: // if variable == 2
doThat();
break;

case 3:
doOther();
break;

case 4: case 5: case 6: // if variable == 4, 5 or 6
doSomethingElse();
break;

default:
doDefault();
break;
}

Inside the parentheses (), you write the variable name that you are testing.
If this variable is an integer, you write:

case 1, case 2, and so on (You can combine cases and include a default case for all other cases).

If it is is a boolean, you would write:

case true, case false.

If it is a String, you would write whichever values that the String variable can take.
For example, if your String can contain any color value, you would use:

case "red", case "blue", and so on.

The purpose of the "break;" is to separate the cases. If you forget to put the break, the code will not stop executing after a case is satisfied. It will keep going. Break can also be used to end loops (which we will discuss in the coming lessons).

__________

Applying this to the example code above,

1. We are testing an integer called randomInt.
2. If randomInt is 0, the computer will output: "Heads!" and break the case.
3. If randomInt is 1, the computer will output: "Tails!" and break the case.

What would be a practical application of this code? Let's say that we have a game in which the player can select one of three characters.
Let's name them Mario, Luigi, and Yoshi.

We would then create a String variable that holds the value of the name, and then use a switch to carry out the appropriate response.

Note: The following will only work in Java 1.7. On Java 1.6 and below, we would use integers to represent our characters, like in the example at this link.
 //Sample Character Selection Screen

class CharacterSelect {

public static void main(String[] args) {

String currentCharacter = "Mario";

int maxLife;
int maxJump;
int maxSpeed;

switch (currentCharacter) {

case "Mario":
System.out.println("You have selected Mario!");
maxLife = 70;
maxJump = 50;
maxSpeed = 25;
break;

case "Luigi":
System.out.println("You have selected Luigi!");
maxLife = 40;
maxJump = 70;
maxSpeed = 30;
break;

case "Yoshi":
System.out.println("You have selected Yoshi!");
maxLife = 50;
maxJump = 30;
maxSpeed = 40;
break;

}

}

}
We store the current character's value in the String variable currentCharacter and use a switch to change the character's attributes.


Tomorrow we will discuss looping. We are getting closer to developing a game, so hang tight and stay tuned!

If you want to thank me for the guide, you can donate here or download TUMBL +!

Thank you guys for reading and I'm here if you have any questions!

Comment below and Like us on Facebook. 
Go to Day 6: If... else...
Go to Day 8: Looping
44 Comments
Reece
11/16/2012 08:11:14 am

really helpful stuff thank you!!!


Reply
Steve
12/10/2012 10:38:39 am

These tutorials are great. I love that you gave an example of how the code could be used. Very helpful, and I look forward to continuing on in these tutorials!

Reply
Dnnis
1/3/2013 10:20:16 am

Thanks Sir very Helpful Tutorial be keeping on it!!

Reply
Robert
1/12/2013 04:59:46 am

hello,
as you have said, if it were a boolean variable we would write "case true" and "case false" but when i try to switch on a boolean variable i get this message:
"Cannot switch on a value of type boolean. Only convertible int values, strings or enum variables are permitted"
example:

public class summerCheck {
static int month = 2;
public static void main(String[] args){
boolean isitSummerAllready;
if (month == 6 || month == 7 || month == 8){
isitSummerAllready = true;
}
else isitSummerAllready = false;

switch (isitSummerAllready){
case true: System.out.println("Awesome, it's summer!");
break;
case false: System.out.println("Darn..");
}
}
}

Reply
zzz
1/13/2013 02:52:46 am

I thought I would never be able to learn Java (and eclipse environment too) by myself but thanks to your awesome work, I'm finding them very interesting. You're examples help to analyze how simple code can be used to implement practical situations in games. Many thanks! :D

Reply
Nathan
1/18/2013 08:54:20 pm

So at first I wanted to rip my hair out but I took deep breaths, had a smoke and came back with a clear mind. I took an intro to Java class in college (7 years ago) and as I continued on it all started to make sense. Well as much sense as I can expect at this point. My one question so far though is in this lesson where we typed

static void testDieValue(int dieValue)

which I understand to be a secondary method, why is the "int" required there. We already established dieValue as an integer with the variable in the beginning. I know I'm wrong, but I want to know why the "int" is necessary again there.

Reply
James
1/20/2013 08:39:07 am

Nathan, the dieValue inside the parameter is not the same dieValue that we declare earlier. We are creating a new dieValue as a local variable (only defined inside the method).

Reply
Sean
2/4/2013 02:29:42 am

James, perhaps for the sake of simplicity, intro courses should really utilize unique naming to avoid such confusion. Once beyond being confused by every single line of code, people will have no issues knowing that something is a global or local variable based solely on location rather than name. But for now, such confusion will make people batty :)

Also, I have noticed that line-by-line documentation for the initial stages of ramping up on a new thing (programming in this instance) is priceless. It would serve to help see if the code is at all confusing to others and would also obviate the need to answer questions such as Nathan's...without being confused, there are no questions :)

Now with all of that said! A HUGE thank you for putting your personal time into helping others learn such a valuable asset. Even if everyone who takes your courses does not become a developer, they will have learned very valuable skills and process to better approach things with a more logical approach.

Mahalo!

Andrew
2/19/2013 06:02:14 am

Thank you for an outstanding set of tutorials.

One observation worth making about BySimpleIMeanSimple is that it incorporates recursion: rollDie calls testDieValue, which, in turn, can call rollDie.

Recursive functions do have their uses, but should be used with care.

In the case of BySimpleIMeanSimple, the recursion is a "tail recursion", in that the call to rollDie in testDieValue is the last statement that is executed within testDieValue if that particular code path is followed. It may be that the compiler can recognize the tail recursion and optimize the code accordingly. But if it doesn't then you have the possibility of a call stack that can grow indefinitely!

Reply
S-Markt
2/27/2013 06:20:17 pm

Great tutorial! Most of the tutorials i watched/red the writer explained how program to himself. you explain it to the readers, so i can understand it not being on the same level of knowledge as you are. thanks a lot. sorry to tell you, that i am unemployed and therefore not able to donate anything today, but if i am able to sell any games on google play, you will get 1% of the first year.

Reply
Prajwal
4/24/2013 02:32:57 pm

This tutorial is very helpful...however my concepts on java and eclipse are not clear...please help

Reply
tejpal
5/2/2013 02:13:52 am

Thank You very much for such a great tutorials.
I copied above code as it is but unable to run it. It says "The value of local variable maxSpeed is not used"
same for maxJump & maxLife.

I don't know what to do please help me.

Reply
Dharmik
6/15/2013 07:29:04 pm

Sir I want to know how String variable is created and used in switches if you help than I will very thankful to you thanks.

Reply
Hughrock
6/30/2013 11:07:45 am

It keeps giving me a syntax error. It says that I need to delete the "new" token. This is my code written as is:

import java.util.Random;


public class CoinToss {
public static void main(String[] args){
Random rand = new Random;
int randomInt = rand.nextInt(2);

switch(randomInt){
case 1: System.out.println("Heads.");
break;
case 0: System.out.println("Tails.");
break;
}
}
}

Reply
Tim
7/28/2013 04:10:27 am

you forget to add "()" after the second Random.

I hope it will work now :)

Reply
Arshad
9/19/2013 10:49:59 pm

You can replace the empty System.out.println(); statements with a "\n" .

Reply
Dharmik vadgama
9/28/2013 08:02:16 pm

Hello sir your tutorial is too helpful but sir i have one question that can i say that only mutually exclusive options is used as case.

Reply
tara
10/3/2013 03:12:35 pm

in programs like this how will an client give a value

Reply
zahid khan
12/23/2013 01:34:46 am


dyr sir i write this code but it not work properly,,,, it doen;t chang the values in switch ..... whts wrong please help me.... i ill be very thankful for u.................



public class simpleswith {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String currt = "zahid";
int a;
int b;
int c;


switch (currt){
case "zahid":
System.out.println("zahid");
a = 23;
b = 45;
c = 51;
break;
case "Waqas":
System.out.println("waqas");
a = 5;
b = 4;
c = 3;
break;
case "ali":
System.out.println("ali");
a = 4;
b = 4;
c = 65;
break;

}

}

}

Reply
Mark
2/9/2014 07:26:31 am

Zahid,

You have to move you int a b and c variables above your main method and use static to make them work throughout the class like this.
static int a;
static int b;
static int c;

public static void main(String[] args) {

}

Reply
Oliver
1/3/2014 02:49:17 pm

Thank you for you work. You did a great job!
Thru your website I learned Java (Eclipse). It simple and easy to understand.
It is Complete. Continue your work so I/We beginner programmer will learn from here.

Reply
Jermaine
1/5/2014 03:48:03 pm

This tutorial could really do with some exercises and even labs. You don't learn code by reading it, you learn by trying it yourself.

The python tutorial 'learn to program games with python and pygame' is a great example of a tutorial, everyone should look to it as an example.

Reply
amano
1/28/2014 11:15:06 am

I'm new to all this, but I want to clarify something. In the example :

switch (randomInt) {

case 1: System.out.println("Heads!");
break;
case 0: System.out.println("Tails!");
break;

This defines our randomInt (through the case) as being 0=tails and 1=heads

However, further into the tutorial, you wrote

1. We are testing an integer called randomInt.
2. If randomInt is 0, the computer will output: "Heads!" and break the case.
3. If randomInt is 1, the computer will output: "Tails!" and break the case.

I know, in this case, it shouldn't really matter much, because we only have two outcome of equal probability, but I just wanted to know whether the value followed after "Case" modifier attributes itself to the randomInt number generated.

Reply
amano
1/28/2014 01:43:16 pm

So to clarify, shouldn''t a randomInt of 0, output "Tails!" and a randomInt of 1, output "Heads!" instead. Since we've already established the case 0 would output "Tails!", and case 1 would output "Heads!".

Or have I misunderstood something.

Reply
Nit
2/7/2014 03:01:40 pm

thank u.. i never thought i wud b doin this.. i hope when i learn all i can finally use some of my creativity in developing somethin..
thank u again.. really appreciate u..

Reply
Noah
2/25/2014 05:17:46 pm

Thanks for the amazing tutorial(s), I have read all sorts of java books (even the ones for dummies) and none of them explain it like you do. Plus the section of character switching seems so simple. Keep up the good work sir!

Reply
Danuel
3/13/2014 12:12:12 pm

I would like to start by saying thank you very much for taking the time to create this tutorial for noobs like me. I am following along fairly well. When you make the statement "Note: The following will only work in Java 1.7. On Java 1.6 and below, we would use integers to represent our characters, like in the example at this link." how do I apply 1.7 to the version of Eclipse that I am doing. I have searched around and followed some of the advice from eclipse.org and other developing sites, yet to no avail. I still receive an error even though I have switched the JRE to 1.7 as well as tried to adjust the workspace for the current project. I also downloaded the most current developer version of Eclipse and restarted all projects from the tutorial and still am not able to get it to work. Any advice, or am i destined to type more code as a result?

Reply
Rodney
4/6/2014 12:14:57 am

Hi, I am having a bit of trouble (Really like your tutorials by the way)

in Eclipse, I ran the program and as you said :'The following will only work in Java 1.7. On Java 1.6 and below' ... this appeared when i ran the program and hovering over the error Eclipse said something like click here to upgrade or fix or something like that... anyways now all my code and the code i have done on the days before now has a red underline to it with the error: "String cannot be resolved to a type" and "System cannot be resolved"

didnt know if you or anyone on here knows why it does this and how to resolve it :)

many thanks

Reply
khalil
4/23/2014 07:43:00 am

I still did not why +1 in{dieValue = rand.nextInt(6) + 1} are number 1 and 6 not inclusive?
please help.

Reply
khalil
4/25/2014 05:29:06 am

This is not a good e.g because the value can not change,
The switch`s(currentcareCharecter) value is already been given as "Mario",
I made a new class exactly as it stated and copied and pasted to make sure i have not missed anything but the code does not give but only "Mario"
it would be appreciated if anyone can help.
class CharacterSelect {

public static void main(String[] args) {

String currentCharacter = "Mario";

int maxLife;
int maxJump;
int maxSpeed;

switch (currentCharacter) {

case "Mario":
System.out.println("You have selected Mario!");
maxLife = 70;
maxJump = 50;
maxSpeed = 25;
break;

case "Luigi":
System.out.println("You have selected Luigi!");
maxLife = 40;
maxJump = 70;
maxSpeed = 30;
break;

case "Yoshi":
System.out.println("You have selected Yoshi!");
maxLife = 50;
maxJump = 30;
maxSpeed = 40;
break;

}

}

}

Reply
Alex
8/10/2014 01:17:51 pm

It looks to me like there is no way in the code for you, or anyone, for that matter, to "choose" another character. I haven't learned how to take user input yet in Java, but in JavaScript it would be like "var currentCharacter = prompt()". I think you need to use a Scanner object, but like I said, I haven't learned that yet.

Reply
Stretch
5/17/2014 07:11:04 pm

ok so i am a lil confused. well i understand everything in the lesson, well i think i do, yet i copied your code across and into a class and ran it, it gives the same answer every time. so im confused:/

it comes up with the thing on the side saying" The value of the local variable maxSpeed is not ued"
it also has the same error for maxJump and maxLife.

is that supposed to be the case?

Reply
Phil
5/21/2014 11:22:02 am

Just want to start by saying what a fantastic tutorial this is. I was/am a complete noob when it comes to anything to do with java and i have learned alot from this so far.

For the "Character Selection" you mentioned that you need Java 1.7, but my question is if Java 1.8 will work as good as 1.7?

I am getting an error for maxJump, maxLife, and maxSpeed saying "The value of local variable maxJump is not used" Any suggestions?

Reply
Pack
5/12/2015 04:54:17 am

I have exactly the same problem. How to fix this anyone ?

Reply
Hitesh
5/27/2014 05:09:19 am

Thanks a lot sir.. awesome tutorials ..
Sir as you mentioned i changed "JRE system library" from CDC-1.1/Foundation1.1(jre8) to Java SE1.7(jre8).
Console panel shows "You have selected Mario!" and when ever i am saving that file is show Yellow triangle with ! sign. and all int shows " The value of the local variable maxSpeed is not used" same for maxJump and maxSpeed..

Please help..
Thanks
.

Reply
ben
5/29/2014 10:17:56 am

I'm stuck on the last example. I copied everything from the link, but when the program terminates this is the only output:

"You have selected Mario!"

I'm really new to this, can someone help me out?

Thanks

Reply
Mebaliko
6/10/2014 02:42:17 pm

I've found plenty of other tutorials but they didn't help me. These are very easy to understand and I am glad that I don't have to pay for them!

Reply
Alex
8/10/2014 01:06:12 pm

This does the same thing and is much more simple, is it incorrect, and if so, why?

import java.util.Random;

public class DiceGame {

public static void main(String[] args){

Random rand = new Random();

int result = rand.nextInt(6)+ 1;

if (result == 1 || result == 2){
System.out.println("You lose.");
}
else if(result == 3 || result == 4 || result == 5){
System.out.println("Roll again.");
}
else if(result==6){
System.out.println("You win!");
}
}
}

Reply
Filipe Teixeira
12/6/2014 12:20:36 am

Apparently you cannot use a String on a switch on Java 1.6. Is it even possible to use Java 1.7 on android?

Reply
Tarl
12/8/2014 03:39:26 pm

For thoes asking why the program keeps comming up with "Mario" as the result, There is nothing in the code that changes currentCharacter. It's defined as Mario. I've added a random integer generator that selects an integer between 0 and 2, then assigns a string with the characters name to currentCharacter, then displays the results and stats of that character. Sorry I'm not great at explaining things... Here's my code:

import java.util.Random;

public class CharacterSelect {

static int maxLife;
static int maxJump;
static int maxSpeed;

public static void main(String [] args){

String currentCharacter = null;
int characterselection;


Random character = new Random();
characterselection = character.nextInt(3);

if (characterselection == 0) {
currentCharacter = "Mario";
}
else if (characterselection == 1){
currentCharacter = "Luigi";
}
else if (characterselection == 2){
currentCharacter = "Yoshi";
}

whodYaGet(currentCharacter);
}
static void whodYaGet(String currentCharacter){

switch (currentCharacter){

case "Mario":
System.out.println("You have selected Mario!");
maxLife = 70;
maxJump = 50;
maxSpeed = 25;
System.out.println("Max Health = " + maxLife);
System.out.println("Max Jump = " + maxJump);
System.out.println("Max Speed = " + maxSpeed);
break;

case "Luigi":
System.out.println("You picked Luigi");
maxLife = 40;
maxJump = 70;
maxSpeed = 30;
System.out.println("Max Health = " + maxLife);
System.out.println("Max Jump = " + maxJump);
System.out.println("Max Speed = " + maxSpeed);
break;

case "Yoshi":
System.out.println ("Yoshi!!");
maxLife = 90;
maxJump = 90;
maxSpeed = 90;
System.out.println("Max Health = " + maxLife);
System.out.println("Max Jump = " + maxJump);
System.out.println("Max Speed = " + maxSpeed);
break;
}
}

}

Reply
zahida link
2/8/2015 02:14:44 pm

How can i use clear method in java with eclipse please

Reply
YaelDD link
8/3/2015 03:06:32 am

It was supposed that I already know Java, and I was going to skip all these "basic tutorials", I decided to check them out and I can't stop reading them, even if they are for "newbies" it is so entertaining to read them and it is so good explaine, I have to say Im very excited because og joining the game development scene and I can bet I will successfully join thanks to you!

Reply
Jonathan
3/11/2016 02:36:14 am

What method can be used to return the actual values for maxLife...etc for the character selected ? can the value for the selected character be fetched and returned in println?

the idea is to have the selected characer's name and attribute's displayed altogether

Reply
Walter
5/8/2017 06:55:06 am

Great work. But the last example is confusing. It would not make any sense to declare and initiate character property fields such as health inside of a main method. I think this can be really confusing for beginners and give them an obstacle on their way to understand OOP. What would have been better I guess is if there where a character object which would be instansiated and it´s values would depent on the name String. Small diffference, but big one for understandig objects. As the values would get attached to an actual character object, rather than being some local variables in a main method.

Reply



Leave a Reply.

    Author

    James Cho is the lead developer at Kilobolt Studios. He is a college student at Duke University and loves soccer, music, and sharing knowledge. 


© 2014 Kilobolt, LLC. All rights reserved.