Showing posts with label theNewBoston. Show all posts
Showing posts with label theNewBoston. Show all posts
Saturday, November 5, 2011 6 comments

9 Amazing Examples of Parsing XML in Android w. Tuts [Source Code] [Video]

Ive found the best way of learning something in Android is to look at about 5 to 10 different varriations of code that accomplish the same thing. Doing this gives you a sense of  whats consistant in all the examples and how you can and can and cant manipulate the code.




1. TheNewBoston/MyBringBack via Youtube:
http://youtu.be/Z1rtldBTzCE


2.Programmer-XR:
http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/


3.AndroidPeople SAX Parsing:
http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser


4.AndroidPeople DOM Parsing:
http://www.androidpeople.com/android-xml-parsing-tutorial-–-using-domparser


5.WarriorPoint:
http://www.warriorpoint.com/blog/2009/07/19/android-simplified-source-code-for-parsing-and-working-with-xml-data-and-web-services-in-android/


6.ctctlabs:
http://www.ctctlabs.com/index.php/blog/detail/parsing_xml_on_android/




7.AndDev User Submitted Tuts by XCaffeinated:
http://www.anddev.org/using_xmlresourceparser_to_parse_custom_compiled_xml-t9313.html


8.AndDev  User Submitted Tuts by PlusMinus:
http://www.anddev.org/parsing_xml_from_the_net_-_using_the_saxparser-t353.html


9.IBM Android Tuts: 
If your new to Android this example and explaination might be a little confusing, its loaded with complicated java jargon experienced developers love to throw around casually as if they were born with such a vocabulary and you should of to, but in reality the reason why programming is complicated isnt because it actually is complicated, its because the people who useually become programmers are complicated. Its there way of scaring away the avg person from ever trying to learn their god like skills.
http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&S_TACT=105AGX59&S_CMP=grlnxw82
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());  
  }  
 }  

Tuesday, October 18, 2011 7 comments

CHALLENGE:Java Tut 36-37-Display Reg Time

The following is a challenge for new developers that have completed:
 Java Tutorial - 36-37 Displaying Regular Time 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.
 

CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:
 
1.Create a class and name it "Time".Unlike classes we've created in the past you dont need to declare a main method.

2.Create 3 int vars. name them hour, minute, second.

3.Create a method,name it setTime, it should accept 3 parameters(int h, int m , int s)
Inside the setTime method:
  • if h is greater than 0 and less than 24 then set h to hour, else set the hour to 0 by default.This should be accomplished in one line of code( Hint:use the "ternary operator" instead of a if statement)
  • if m is greater than 0 and less than 60 then set m to minute, else set the minute to 0 by default.(Hint: "ternary operator")
  • if s is greater than 0 and less than 60 then set s to second, else set the second to 0 by default.(Hint: "ternary operator")
End "setTime" method 

4.Create another method.Name it toMilitary.
Inside the to Military method:
  • Create a return statement that will format the "hour" , "minute" and "second" vars to display in military format.
    Example of console output:18:30:00
    End "toMilitary" method
5.Create a method,name it toRegTime
Inside the "toRegTime" method:
  • Create a return statement that will format the "hour" , "minute" and "second" vars to display in standard time format. (hint:Ull need to use the Modulus (%) operator
    Example of console output:6:30:00 PM
End "toRegTime" method

End of "Time" class

6.Create another class and name it testTime .Create a main method.

Inside the main method of testTime class:
  • Declare a new Time object and name it tickTock.
  • Print tickTock.toMilitary
  • Print tickTock.toRegTime
  • Call the setTime method with the parameters (13,27,6)
  • Print tickTock.toMilitary
  • Print tickTock.toRegTime
End of "testTime" class
COMPILE & PRAY TO DUKE!!!
View the video tutorial: http://bit.ly/qkxfja 

Wednesday, October 12, 2011 0 comments

CHALLENGE:Java Tut 35-Var Length Arguments

The following is a challenge for new developers that have completed:
 Java Tutorial - 35 Variable Length Arguments 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/3
Create a console program with a method that finds the average of a unknown amount of numbers(aka accepts a variable length argument in its parameters)Then test it in you're main method.

CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:
 
1.Create a method that will return a int and name it "average".It should accept a variable length argument, name the variable length argument "numbers"

Inside the "average" method:

2.Declare a int variable, name it total and set it to 0.

3.Create a enhanced for loop that loops through the "numbers" parameter being passed in.

Inside the enhanced for loop:
4.set total+=x;

5.return total divided by the amount of numbers you passed in(hint: numbers.length)

Back in the main method:


6.Create a print line statement that calls the "average" method and place 8 values in its parameters.


COMPILE & PRAY TO DUKE!!!


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

Tuesday, October 11, 2011 0 comments

CHALLENGE:Java Tut 32-34-Arrays in Methods & Multidimensional Arrays

The following is a challenge for new developers that have completed:
 Java Tutorial's 32-34 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 java console program with a method that accepts a multidimensional array in its parameters.When the method is called it should print the array out to the console as a table.If you've done everything right you're results should look like this:


This is the the Multi Array
8        9        5          12
55      12        32         22
15       4        39         83




CHALLENGE!!
(Before starting any of the challenges always declare a class and a main method unless told otherwise)
 Difficulty:★2/3
1.Create a multidimensional array. It should have at least 3 arrays inside of it and each array should have several values.

2.Create a method that accepts a multidimensional array in its parameters, name the array in the parameters "x" and name the method "display"[

3.Inside the display method create a for loop, name you're counter "row; loop  through until x.length is less than "row" ; increment by 1

Inside of the "row" for loop insert: [

  • Another for loop. name you're counter "column"; loop  through until x.length is less than "x[row].length;increment by 1. Inside the "column" for loop insert:


  •    1.A print line statement that prints  x[row][column] + "\t"]

  • Print line statement that prints: a blank line] ]


    • 4.In the main method write a print line statement that reads "This is the array table"

      5.In the main method call the display method and place you're array in the parameters

      Note: I am trying to experiment to find the best way to explain loops in words. Everything that is Orange is inside of the "Row" for loop and everything that is red is inside the "column" for loop. If this made it easier for you to understand or you have some suggestions to improve these challenges leave it in a comment below!!


      COMPILE & PRAY TO DUKE!!!
      View the video tutorial: http://bit.ly/r9jFZN
      Monday, October 10, 2011 1 comments

      WALKTHROUGH:TNB Java Tut 26-Random Number Generator[VIDEO & SOURCE CODE]]

      This is a full walkthrough of Java Tutorial 26 by TheNewBoston. Each walkthrough includes:
      • Embedded Video Tutorial
      • Text Transcript of the tutorial broken down into steps.
      • Source code
      If you found this walkthrough helpful and want to see more of them please leave a comment and let me know.Im trying alot of new things and still trying to get a feel for what people want more of.You're feedback counts around here!!!



      Step 1.Import the Random package
       import java.util.Random;  
      

      Step 2. Declare a new Random variable and name it "dice"
       Random dice=new Random();  
      

      Step 3. Declare a int variable and name it "number"
       int number;  
      

      Step 4. Create a "for" loop that will loop through 10 times before stopping.

       for(int counter =0;counter<10;counter++){  
       }  
      

      Step 5. Inside the for loop:
      • Set the number var to equal a random number between 1-6
      •   number=1+dice.nextInt(6);  
        
      •  Print the random number variable + a space (" ")
      •   System.out.println(number +" ");  
        
      End of Tutorial

       TNB Java Tut 26 Complete Source Code 

       import java.util.Random;  
       class TNBjtut26{  
        public static void main(String[] args){  
       Random dice=new Random();  
       int number;  
       for(int counter =0;counter<10;counter++){  
        number=1+dice.nextInt(6);  
        System.out.println(number +" ");  
       }  
          }  
       }  
      
      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.

      Friday, October 7, 2011 0 comments

      CHALLENGE:Java Tut 26-Random Number Generator

      The following is a challenge for new developers that have completed:
      Intermediate Java Tutorial - 26 -Random Number Generator by theNewBoston
       


      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 java console program that simulates rolling  a standard 6 sided die(the single form of dice)  10 times and print out the results in the console with a space. The results should look something like this:  
      3 7 2 2 1 ect... up  to 10


      CHALLENGE!!
      (Before starting any of the challenges always declare a class and a main method unless told otherwise)
       Difficulty:
      1. Declare a new Random variable and name it "dice"
      2. Declare a int variable and name it "number"
      3. Create a "for" loop that will loop through 10 times before stopping.
                (hint: initialization; termination; increment
      4. Inside the for loop set the number var to equal a random number between 1-6(hint: "dice.")
      5.Print the random number variable + a space (" ")
      ( If you dont add the space when you run it all youre numbers will be in one jumbled line.)

      View the video tutorial: http://bit.ly/pLAzeg
      0 comments

      Introducing B.A.M.F Challenges

       (B.A.M.F's Make Money Like George Jung From Blow and you will to once you master the art of I2J Translation)

      B.A.M.F Challenges are for those of you feeling a little cocky, Instead of giving you step by step directions I will only give you a abstract goal of the challenge and its up to you to figure out how to make it happen.Even if you cant always complete the B.A.M.F challenge, you should always at least try and then move down to the reg challenge if youre struggling.B.A.M.F Challenges help youre brain become what I call a Java "translator" , as in you can listen to a client explain something they want done in simple English and convert it in you're mind to rough Java.Almost every new programmer gets to a point where they can read source code and understand what its doing, but struggle with creating a program from a idea alone without help or alot of research.The end results should still be the same as the regular challenge.
      Monday, July 18, 2011 2 comments

      CHALLENGE: Intermediate Java Tut's 4&5

      The following is a challenge for new developers that have completed:
      Intermediate Java Tutorial - 4&5 -Collections & arrayLists by theNewBoston



      Legendary Challenge: 
      Difficulty: ★ 1/2

      Create two arrayLists, the first array must have 5 unique strings and the second array must consist of only the last 2 strings from the first array.Then create a method that will iterate through the first arrayList and filter out any strings that are also in the second array. Print your results.

      Legendary Challenges consist of only a very broad description of the challenge making them a little harder.The end results should still be the same as the regular challenge.

      CHALLENGE 
       Difficulty:
      1. Create a String array named "things" containing the strings "eggs", "lasers","hats" and "pie"
      2. Create a new ArrayList named "list1"
      3. Create a For loop that adds the items from the array "things" to "list1"
      4. Create a String array named "things2" containing only the strings "lasers" & "hats" 
      5. Create a new ArrayList named "list2"
      6. Create a For loop that adds the items from the array "things2" to "list2"
      7.Print all the strings in list1 one using a for loop

      End of Tut 4/Start of Tut 5

      8.Create a method a called editList that uses two collection parameters and names them "A1" and "A2"
      (to make it less confusing just remember that in a later step we will call the editList method and use "list1" & "list2" as parameters) 

      9. Inside the editList method loop through each string in "A1" and make sure none of the strings are the same as any of the strings in "A2" 

      10.If any of the strings from "A1" do match any of the strings from "A2" delete the string from "A1"

      11.Call the editList method using "list1" & "list2" as parameters

      12.Print a blank line

      13.Print each of the strings in list1 using a for loop 

      Note: Please keep in mind this blog is a work in progress and ive learned quickly that teaching is alot harder than just following along . If something is explained poorly or you have a suggestion to reword a step please leave a comment below so we can make this the best resource possible for up and coming developers.


      View the video tutorial: http://youtu.be/jU5ACV5MucM
                     Text walk-through of this tutorial: Coming Soon!!!


      2 comments

      CHALLENGE:Intermediate Java Tut 6-LinkedList

      The following is a challenge for new developers that have completed:
      Intermediate Java Tutorial - 6 -LinkedList by theNewBoston
       

      CHALLENGE!!
      (Before starting any of the challenges always declare a class and a main method unless told otherwise)
       Difficulty:
      1. Create a String array named "things" with 5 items.
      2. Create a new LinkedList named "list1"
      3. Create a For loop that adds the items from the array "things" to "list1"
      4.Create a String array named "things2" with 4 items.
      5.Create a new LinkedList named "list2"
      6.Create a For loop that adds the items from the array "things2" to "list2"
      7. add all the items on list2 to list1
      8.Set list2 to null

      View the video tutorial: http://youtu.be/BRcY2vIr-EQ
      Text walkthrough of this tutorial: Coming Soon!!!
       
      ;