Skip to content

Commit

Permalink
added 8.15.13
Browse files Browse the repository at this point in the history
  • Loading branch information
secbajor committed Aug 15, 2013
0 parents commit bb22f87
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
35 changes: 35 additions & 0 deletions NinjaWarrior.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

public class NinjaWarrior {

//declare all private variables (add one for each stat)
private int str;

/**
* this "constructs" an instance of our NinjaWarrior object
* we pass it a variable as an "argument" for each "stat" that our NinjaWarrior has
* so far, he only has one stat (strength) and I have chosen "int s" as the argument to represent that stat
* between the brackets, we set each private variable (str) equal to its corresponding argument (s)
*/
NinjaWarrior(int s)
{
str = s;
}

/**
* this is an example of a "set method"
* set methods allow us to UPDATE the value of a stat
*/
public void setStr(int s)
{
str = s;
}

/**
* this is an example of a "get method"
* get methods allow us to access the value for a stat, which is helpful for when we want to print that stat
*/
public int getStr()
{
return str;
}
}
21 changes: 21 additions & 0 deletions main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

public class main {

/**
* @param args
*/
public static void main(String[] args) {

//creates a NinjaWarrior object named player
NinjaWarrior player = new NinjaWarrior(10);

//we can run any of our methods on player using "player.methodNameHere
System.out.println("Starting strength is "+player.getStr());
player.setStr(14); //updates the strength to 14
System.out.println("Strength is now "+player.getStr());



}

}

0 comments on commit bb22f87

Please sign in to comment.