Showing posts with label walk-through. Show all posts
Showing posts with label walk-through. Show all posts
Friday, October 28, 2011 3 comments

WALKTHROUGH:TNB Java Tut 50 -"Graphical User Interface GUI" [VIDEO] [SOURCE CODE]

In this walk-through you will create a simple GUI that will use 2 shoInputDialogs and a showMessageDialog to find the sum of two numbers input from the user. 
 
Whats New In This Walk-Through:
  • showInputDialog's- A graphical box that users can input data from
  • Integer.parseInt - A method used to convert a string number to a int var
  • Using showMessageDialog's-A graphical box that can display a message




    Step 1. Import javax.swing.JOptionPane:

    Photobucket

    Step 2. Declare a class and a main method:


    Step 3.Create 2 String variable and set them equal to a showInputDialog:



    Step 4. Create two int variable and set them equal to the Strings we collected from the user via the showInputDialog (you will need to parse the strings before you can set them equal to a int variable):



    Step 5.Create a third int var and set it equal to the sum of int var1 and int var2:



    Step 6. Create a showMessageDialog that will display the sum of the two numbers in sentence form:

    TNB Java Tut 50 Source Code:

     import javax.swing.JOptionPane;  
     class apples {  
       public static void main(String[] args){  
        String fn = JOptionPane.showInputDialog("Enter first number");  
        String sn = JOptionPane.showInputDialog("Enter second number");  
        int num1 = Integer.parseInt(fn);  
        int num2 = Integer.parseInt(sn);  
        int sum = num1 + num2;  
        JOptionPane.showMessageDialog(null, "The answer is " + sum, "the title", JOptionPane.PLAIN_MESSAGE);  
       }  
     }  
    


    End of Tutorial
    Wednesday, October 26, 2011 3 comments

    WALKTHROUGH:TNB Java Tut 49 -"Inheritance" [VIDEO] [SOURCE CODE]

    This is a full walk-through of Java Tutorial 49-"Inheritance" by TheNewBoston.This walk-through includes:
    • Embedded Video Tutorial
    • Alternative explanation & source code
    • Visual Breakdown of the code
    In this walk-through you will learn about using the "toString" method, a very useful method used to give any object a default string representation.





    Super Classes:Super classes are alot like super stars(celebrity's)that influence us.You might never be Kanye west, but from listening/watching  to him you can inherit some of his talents and beliefs(methods). Think of "super classes" as "super stars" that you're regular classes look up to.
     public class superStarKanyeWest{  
       public void rap(){  
       System.out.println("yo yo yo");  
     }  
       public void makeBeats(){  
       System.out.println("BOOM BOOM shimmy BOOM BOOM");  
     }  
       public void personalPhilosophy(){  
       System.out.println("Shoot for the stars so if you fall you land on a cloud.");  
     } 
       public void politicalBeliefs(){  
       System.out.println("George Bush does not care about black people.");  
     }  
     }  
    
    (Example of a "Super Class")




    Joe Nobody is just a normal teenager, he himself has no super powers, but hes a fan of Kanye's and aspires to one day become a world famous rapper.Because Kanye inspires Joe we could say Joe is a extension of what Kanye represents because we are all extensions of the people who inspire us.    
    OVERIDE:In the java world because Joe looks up to (extends) Kanye by default he inherits all of Kanyes public methods, but Joe can also overwrite individual methods he disagrees with Kanye about, such as political beliefs.
     
    Even thought Joe inherited alot of his talents and qualitys(methods) from studying Kanye, Joe is still unique and can have talents(methods) of his own Kanye doesn't such as knowing how to play the guitar.
     public class joeNobody extends superStarKanyeWest{  
      int age=18;  
         public void playGuitar(){  
        System.out.println("I can play guitar");  
      }  
         public void politicalBeliefs(){  
       System.out.println("All politicians are evil crooks and talking politics just gets people pissed off so I just stay out of that stuff.");  
         }   
     }  
    
    (joeNobody Class)


    Bobby is Joes little brother, bobby looks up to Joe.Bobby doesn't even know who Kanye is yet,but Because some of Joes quality's are inherited from Kanye,Bobby inherits the the quality's Joe picked up from Kanye as well as all of Joes unique quality's. 
    Because Joe overode Kanyes political beliefs Bobby will share Joes politicalBeliefs.
    playBasketball() is a method unique to bobby
     public class bobbyNobody extends joeNobody{  
      int age=15;  
          public void playBasketballGood(){  
        System.out.println("I can shoot 10 for 10 from the free throw line.");  
      }  
     }  
    
    (bobbyNobody Class)

    End of Tutorial
    Monday, October 24, 2011 3 comments

    WALKTHROUGH:TNB Java Tut 42 -"toString" [VIDEO] [SOURCE CODE]

    This is a full walk-through of Java Tutorial 42 by TheNewBoston. Each walk-through includes:
    • Embedded Video Tutorial
    • Text Transcript of the tutorial broken down into steps.
    • Source code
    • Visual Breakdown of the code
    In this walk-through you will learn about using the "toString" method, a very useful method used to give any object a default string representation.


    Step 1.Create a class and name it "stringDinger"
     public class stringDinger {  
     }  
    
    inside of the "stringDinger" class:

    Step 2.Create 3 int vars(month, day, year)
      private int month;  
      private int day;  
      private int year;  
    

    Step 3.Create a constructor for the "stringDinger" class that accepts 3 parameters.
     public stringDinger(int m,int d,int y){  
    
    inside of the stringDinger constructor:

    Step 4.Set each of the incoming parameters to their corresponding variables:
      month=m;  
       day=d;  
       year=y;  
    

    Step 5.create a print function statement that prints the sentence "the constructor for this is %s\n , this"(note: "using "this" in this case will equal whatever you're "toString" method returns )
      System.out.printf("the constructor for this is %s\n",this);  
    
    end of stringDinger constructor.

    Step 6.Create a "toString" method that returns the variables formated like this : "month/day/year":
      public String toString(){  
       return String.format("%d/%d/%d",month,day,year);  
      }  
    
    end of "stringDinger" class

    Step 7.Create a new class with a main method, name the class "useTheDinger"
     class useTheDinger{  
      public static void main(String[] args){  
     }  
     }  
    
    inside the  main method of the "useTheDinger" class:

    Step 8.Create a stringDinger object with the parameters 4,5,2011
      stringDinger theDingerSpeaks = new stringDinger(4,5,6);  
    

    End of Tutorial
     TNB Java Tut 46 Complete Source Code 


    "stringDinger" Class

     public class stringDinger {  
      private int month;  
      private int day;  
      private int year;  
      public stringDinger(int m,int d,int y){  
       month=m;  
       day=d;  
       year=y;  
       System.out.printf("the constructor for this is %s\n",this);  
     }  
      public String toString(){  
       return String.format("%d/%d/%d",month,day,year);  
      }  
     }  
    

    "useTheDinger" Class

     class useTheDinger{  
      public static void main(String[] args){  
       stringDinger theDingerSpeaks = new stringDinger(4,5,6);  
       System.out.println(theDingerSpeaks.toString());  
      }  
     }  
    

    Monday, October 10, 2011 0 comments

    CHALLENGE:Java Tut's 27&28-Intro to Arrays

    The following is a challenge and or walk-through for new developers that have completed:
    Java Tutorial - 27&28 -Introduction to Arrays by theNewBoston
    To get the most out of these challenges try them a few hours or the day after watching/following along with the actual video.
     


    B.A.M.F Challenge:
    B.A.M.F Challenges & why you want to always at leas try them explained Here:http://bit.ly/ogivqe
    Difficulty: ★ 1/2
     Create a int array and loop through each entry in a 2 column list .You're results should look like this:

    Index     Value
    0              18
    1               24
    2                 8
    ect....
    _________________________________________________________________________________

    CHALLENGE!!
    (Before starting any of the challenges always declare a class and a main method unless told otherwise)
     Difficulty:
    1.Create a int array with 5 values of you're choosing.
    2.Create a print line statement with the words Index , a few spaces and Values ( like the example in the BAMF challenge above.
    3.Create a for loop that will continue to loop until you're counter is greater than the length of the array you created , increment by one. Each time it loops:
                        * Print the Index & Value (hint: use the counter from you're for loop)

    View the video tutorial: http://bit.ly/omhcMV 



    If this tutorial was helpful for you or you have suggestions as to how I can improve this series please leave a comment below, You're voice will be heard and I will make what ever improvements I can.

     
    ;