Download presentation
Presentation is loading. Please wait.
Published byJohnathan Melis Modified over 10 years ago
2
private static boolean invertBool(boolean org) { boolean returnValue = false; if (org) { returnValue = false; } if (!org) { returnValue = true; } return returnValue; } Calling this method: if (invertBool(isPrimeNumber()) ……….
3
public StandardResponse UnSubscribeUserAccount( String opTionID, String email, String sellingRegion, String sourcecode, String opt_out_date, String streetname, String optionID) { ……………. }
4
public class Enemy { public int maxEnemyLives(int enemyNum) { int lives=0; if (enemyNum==1) lives=10; if (enemyNum==2) lives=50; if (enemyNum==3) lives=30; lives=20; return lives; } private void minEnemyLives(int enemyNum) { return maxEnemyLives(enemyNum) – 5; } Calling this method: int heartRate = maxEnemyLives(3); ……….
5
public static int getSubType(int mainType) { int subType = 0; while(true) { if(mainType == 7) { subType = 4; break; } if(mainType == 9) { subType = 6; break; } if(mainType == 11) { subType = 9; break; } break; } return subType; } Calling this method: int main = 8; int sub = getSubType(main); ……….
6
// This method returns an integer depending on the string private static int countVowels(String str) { int count=0, sum=0; String vowels = “aeiouAEIOU”; String v1=“a”, v2=“e”, v3=“i”, v4=“o”, v5=“u”; for (int i=0; i<str.length(); i++) { if (vowels.indexOf(str.substring(i, i+1))>=0) count++; sum+=count; } return count; } Calling this method: String name = “Charlie Brown”; int vowelCount=countVowels(name); ……….
7
public static String concat1(String s1, String s2, String s3, String s4, String s5, String s6) { String result = ""; result += s1; result += “ “ + s2; result += “ “ + s3; result += “ “ + s4; result += “ “ + s5; result += “ “ + s6; return result; } Calling this method: String sentence = concat1(“I”, “am”, “a”, “Career”, ”Center”, “teacher”); ……….
8
public static String getLastLetter(ArrayList letters) { for (int i=0; i<letters.size(); i++) { if ( i == letters.size()-1 ) return letters.get(i); } return “?”; } Calling this method: ArrayList list = ……….. ………. String last = getLastLetter(list); ……….
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.