Skip to content
Browse files

changes

  • Loading branch information...
1 parent 21fb359 commit c20957c4adf007d9ab89893a5cf67740d28b9f0c @varun06 committed Apr 20, 2012
View
BIN BeerSong.class
Binary file not shown.
View
21 BeerSong.java
@@ -0,0 +1,21 @@
+public class BeerSong {
+ public static void main (String[] args) {
+ int beerNum = 99;
+ String word = "bottles";
+ while (beerNum > 0) {
+ if (beerNum == 1) {
+ word = "bottle"; // singular, as in ONE bottle.
+ }
+ System.out.println(beerNum + " " + word + " of beer on the wall");
+ System.out.println(beerNum + " " + word + " of beer.");
+ System.out.println("Take one down.");
+ System.out.println("Pass it around.");
+ beerNum = beerNum - 1;
+ if (beerNum > 0) {
+ System.out.println(beerNum + " " + word + " of beer on the wall");
+ } else {
+ System.out.println("No more bottles of beer on the wall");
+ } // end else
+ } // end while loop
+ } // end main method
+} // end class
View
BIN Books.class
Binary file not shown.
View
4 Books.java
@@ -0,0 +1,4 @@
+class Books{
+ String title;
+ String author;
+}
View
BIN BooksTestDrive.class
Binary file not shown.
View
28 BooksTestDrive.java
@@ -0,0 +1,28 @@
+class BooksTestDrive{
+ public static void main(String[] args) {
+
+ Books [] myBooks = new Books[3];
+
+ int x = 0;
+
+ myBooks[0] = new Books();
+ myBooks[1] = new Books();
+ myBooks[2] = new Books();
+
+ myBooks[0].title = "The Grapes of Java";
+ myBooks[1].title = "The Java Gatsby";
+ myBooks[2].title = "The Java CookBook";
+
+ myBooks[0].author = "bob";
+ myBooks[1].author = "sue";
+ myBooks[2].author = "ian";
+
+ while(x<3){
+ System.out.print(myBooks[x].title);
+ System.out.print(" by ");
+ System.out.print(myBooks[x].author);
+ System.out.println(" ");
+ x += 1;
+ }
+ }
+}
View
BIN Clock.class
Binary file not shown.
View
11 Clock.java
@@ -0,0 +1,11 @@
+class Clock{
+ private String time;
+
+ public void setTime(String t){
+ time = t;
+ }
+
+ public String getTime(){
+ return time;
+ }
+}
View
BIN ClockTestDrive.class
Binary file not shown.
View
9 ClockTestDrive.java
@@ -0,0 +1,9 @@
+class ClockTestDrive{
+ public static void main(String[] args) {
+ Clock c = new Clock();
+
+ c.setTime(123);
+ String tod = c.getTime();
+ System.out.println("time: " + tod);
+ }
+}
View
BIN Dog.class
Binary file not shown.
View
37 Dog.java
@@ -0,0 +1,37 @@
+class Dog{
+ String name;
+ public static void main(String[] args) {
+ //make a Dog object and access it
+
+ Dog dog1 = new Dog();
+ dog1.bark();
+ dog1.name = "Bart";
+
+ //now make a Dog Array
+
+ Dog[] myDogs = new Dog[3];
+
+ //and put some dogs in it
+ myDogs[0] = new Dog();
+ myDogs[1] = new Dog();
+ myDogs[2] = dog1;
+
+ //now access the Dogs using the array referneces
+ myDogs[0].name = "Fred";
+ myDogs[1].name = "Marge";
+
+ System.out.println("last dog's name is");
+ System.out.println(myDogs[2].name);
+
+ int x = 0;
+
+ while(x<myDogs.length){
+ myDogs[x].bark();
+ x += 1;
+ }
+
+ }
+ public void bark(){
+ System.out.println(name + " says Ruff!");
+ }
+}
View
BIN DrumKit.class
Binary file not shown.
View
12 DrumKit.java
@@ -0,0 +1,12 @@
+class DrumKit{
+ boolean topHat = true;
+ boolean snare = true;
+
+ void playSnare(){
+ System.out.println("bang bang ba-bing");
+ }
+
+ void playTopHat(){
+ System.out.println("ding ding da-ding");
+ }
+}
View
BIN DrumKitTestDrive.class
Binary file not shown.
View
11 DrumKitTestDrive.java
@@ -0,0 +1,11 @@
+class DrumKitTestDrive{
+ public static void main(String[] args) {
+ DrumKit d = new DrumKit();
+ if(d.snare == true){
+ d.playSnare();
+ }
+ d.snare = false;
+
+ d.playTopHat();
+ }
+}
View
BIN Echo.class
Binary file not shown.
View
6 Echo.java
@@ -0,0 +1,6 @@
+class Echo{
+ int count = 0;
+ void hello(){
+ System.out.println("helloooo....");
+ }
+}
View
BIN EchoTestDrive.class
Binary file not shown.
View
31 EchoTestDrive.java
@@ -0,0 +1,31 @@
+public class EchoTestDrive{
+ public static void main(String[] args) {
+ Echo e1 = new Echo();
+ // Echo e2 = new Echo();
+ Echo e2 = e1;
+
+ int x = 0;
+
+ while(x<4){
+ e1.hello();
+ e1.count = e1.count + 1;
+ System.out.println("Value of e1.count " + e1.count);
+
+ if (x == 3) {
+ e2.count = e2.count + 1;
+ System.out.println("Value of e2.count in three condition" + e2.count);
+ }
+
+ if (x > 0) {
+ e2.count = e2.count + e1.count;
+ System.out.println("Value of e2.count, in four condition " + e2.count);
+
+ }
+
+
+ x = x + 1;
+
+ }
+ System.out.println(e2.count);
+ }
+}
View
BIN GameLauncher.class
Binary file not shown.
View
6 GameLauncher.java
@@ -0,0 +1,6 @@
+public class GameLauncher{
+ public static void main(String[] args) {
+ GuessGame game = new GuessGame();
+ game.startGame();
+ }
+}
View
BIN GetHeapSize.class
Binary file not shown.
View
6 GetHeapSize.java
@@ -0,0 +1,6 @@
+public class GetHeapSize{
+ public static void main(String[] args) {
+ long heapSize = Runtime.getRuntime().totalMemory();
+ System.out.println("Heap Size = " + heapSize);
+ }
+}
View
BIN GuessGame.class
Binary file not shown.
View
64 GuessGame.java
@@ -0,0 +1,64 @@
+public class GuessGame{
+ Player p1; //Instance variables
+ Player p2;
+ Player p3;
+
+ public void startGame(){ //a method
+ p1 = new Player(); //Create three player objects and assign them to player instance variables
+ p2 = new Player();
+ p3 = new Player();
+
+ int guessp1 = 0; //declare integer variables to hold values
+ int guessp2 = 0;
+ int guessp3 = 0;
+
+ boolean p1isRight = false; //declare boolean variables to hold values
+ boolean p2isRight = false;
+ boolean p3isRight = false;
+
+ int targetNumber = (int)(Math.random()*10);
+ System.out.println("I am thinking of a number between 0 and 9...");
+
+ while(true){
+ System.out.println("Number to guess is " + targetNumber);
+
+ p1.guess();
+ p2.guess();
+ p3.guess();
+
+ guessp1 = p1.number;
+ System.out.println("Player one guessed " + guessp1);
+
+ guessp2 = p2.number;
+ System.out.println("Player two guessed " + guessp2);
+
+ guessp3 = p3.number;
+ System.out.println("Player three guessed " + guessp3);
+
+ if(guessp1 == targetNumber){
+ p1isRight = true;
+ }
+
+ if(guessp2 == targetNumber){
+ p2isRight = true;
+ }
+
+ if(guessp3 == targetNumber){
+ p3isRight = true;
+ }
+
+ if(p1isRight||p2isRight||p3isRight){
+ System.out.println("We have a winner!");
+ System.out.println("Player one got it right? " + p1isRight);
+ System.out.println("Player two got it right? " + p2isRight);
+ System.out.println("Player three got it right? " + p3isRight);
+ System.out.println("Game is over.");
+ break;
+ } else {
+ System.out.println("Players will have to try again.");
+ }
+ }
+
+
+ }
+}
View
BIN Hobbits.class
Binary file not shown.
View
24 Hobbits.java
@@ -0,0 +1,24 @@
+public class Hobbits{
+ String name;
+
+ public static void main(String[] args) {
+ Hobbits [] h = new Hobbits[3];//object array
+ int z = 0;
+
+ while(z<3){
+ h[z] = new Hobbits(); //new Hobbit type
+ h[z].name = "bilbo";
+
+ if(z == 1){
+ h[z].name = "frodo";
+ }
+
+ if(z == 2){
+ h[z].name = "sam";
+ }
+ System.out.print(h[z].name + " is a ");
+ System.out.println("good Hobbit name");
+ z += 1;
+ }
+ }
+}
View
BIN PhraseOMatic.class
Binary file not shown.
View
27 PhraseOMatic.java
@@ -0,0 +1,27 @@
+public class PhraseOMatic{
+ public static void main(String[] args) {
+ //make three sets of words to choose from
+ String[] wordListOne = {"24/7","multi-tier","30,000 foot","B-to-B"};
+ String[] wordListTwo = {"empowered","sticky","Oriented","centric"};
+ String[] wordListThree = {"process","tipping point","solution","architecture"};
+
+ //find out how many words are in each list
+
+ int oneLength = wordListOne.length;
+ int twoLength = wordListTwo.length;
+ int threeLength = wordListThree.length;
+
+ //generate three random numbers
+
+ int rand1 = (int)(Math.random()*oneLength);
+ int rand2 = (int)(Math.random()*twoLength);
+ int rand3 = (int)(Math.random()*threeLength);
+
+ String phrase = wordListOne[rand1]+" " + wordListTwo[rand2] +" " + wordListThree[rand3];
+
+ //print the phrase
+
+ System.out.println("What we need is a " + phrase);
+
+ }
+}
View
BIN Player.class
Binary file not shown.
View
9 Player.java
@@ -0,0 +1,9 @@
+public class Player{
+ int number = 0;
+
+ public void guess(){
+ number = (int)(Math.random()*10);
+ System.out.println("I'm guessing " + number);
+
+ }
+}
View
BIN PoolPuzzleOne.class
Binary file not shown.
View
26 PoolPuzzleOne.java
@@ -0,0 +1,26 @@
+class PoolPuzzleOne{
+ public static void main(String[] args) {
+ int x = 0;
+
+ while(x<4){
+ System.out.print("a");
+ if(x<1){
+ System.out.print(" ");
+ }
+ System.out.print("n");
+ if(x>1){
+ System.out.print(" oyster");
+ x = x + 2;
+
+ }
+ if(x == 1){
+ System.out.print("noys");
+ }
+ if(x<1){
+ System.out.println("oise");
+ }
+ System.out.println("");
+ x = x + 1;
+ }
+ }
+}
View
BIN Shuffle1.class
Binary file not shown.
View
11 Shuffle1.java
@@ -0,0 +1,11 @@
+class Shuffle1{
+ public static void main(String[] args) {
+ int x = 0;
+ int y = 0;
+ while(x<5){
+ y = x - y;
+ System.out.print(x+ " "+y + "");
+ x = x + 1;
+ }
+ }
+}
View
BIN TapeDeck.class
Binary file not shown.
View
11 TapeDeck.java
@@ -0,0 +1,11 @@
+class TapeDeck{
+ boolean canRecord = false;
+
+ void playTape(){
+ System.out.println("tape playing");
+ }
+
+ void recordTape(){
+ System.out.println("tape recording");
+ }
+}
View
BIN TapeDeckTestDrive.class
Binary file not shown.
View
14 TapeDeckTestDrive.java
@@ -0,0 +1,14 @@
+class TapeDeckTestDrive{
+ public static void main(String[] args) {
+
+ TapeDeck t = new TapeDeck();
+
+ t.canRecord = true;
+ t.playTape();
+
+ if(t.canRecord == true){
+ t.recordTape();
+ }
+
+ }
+}
View
BIN Test1.class
Binary file not shown.
View
20 Test1.java
@@ -0,0 +1,20 @@
+public class Test1{
+ static int x = 5; //define a global variable
+ public static void main(String[] args) {
+ while(x>1){ //loop for x
+ int x = 1; //define local variable
+ x -= 1;
+ while(x<10){
+ x += 1;
+ if(x<=3){
+ if(x>3){
+ System.out.println("small x"); //print the value
+ System.out.println("big x"); //print the value
+ }
+
+ }
+ }
+
+ }
+ }
+}
View
BIN TestArrays.class
Binary file not shown.
View
28 TestArrays.java
@@ -0,0 +1,28 @@
+class TestArrays{
+ public static void main(String[] args) {
+
+ int y = 0;
+ int [] index = new int[4];
+ index[0] = 1;
+ index[1] = 3;
+ index[2] = 0;
+ index[3] = 2;
+
+ String [] islands = new String[4];
+
+ islands[0] = "Bermuda";
+ islands[1] = "Fiji";
+ islands[2] = "Azores";
+ islands[3] = "Cozmul";
+
+ int ref;
+
+ while(y<4){
+ ref = index[y];
+
+ System.out.print("island = ");
+ System.out.println(islands[ref]);
+ y = y + 1;
+ }
+ }
+}
View
BIN Triangle.class
Binary file not shown.
View
27 Triangle.java
@@ -0,0 +1,27 @@
+class Triangle {
+ double area;
+ int height;
+ int length;
+ public static void main(String [] args) {
+ int x = 0;
+ Triangle [] ta = new Triangle[4];
+ while (x < 4) {
+ ta[x] = new Triangle();
+ ta[x].height = (x + 1) * 2;
+ ta[x].length = x + 4;
+ ta[x].setArea();
+ System.out.print("triangle "+x+", area");
+ System.out.println(" = " + ta[x].area);
+ x += 1;
+ }
+ int y = x;
+ x = 27;
+ Triangle t5 = ta[2];
+ ta[2].area = 343;
+ System.out.print("y = " + y);
+ System.out.println(", t5 area = "+ t5.area);
+ }
+ void setArea() {
+ area= (height * length) / 2;
+ }
+}
View
BIN XCopy.class
Binary file not shown.
View
13 XCopy.java
@@ -0,0 +1,13 @@
+class XCopy{
+ public static void main(String[] args) {
+ int orig = 42; // primitive type
+ XCopy x = new XCopy(); //create an object
+ int y = x.go(orig); //assign the return value
+ System.out.println(orig + " " + y);
+ }
+
+ int go(int arg){ //method declaration and method
+ arg = arg * 2; // is returning int value
+ return arg;
+ }
+}
View
BIN abecedarian.class
Binary file not shown.
View
21 abecedarian.java
@@ -12,21 +12,22 @@ public static boolean isAbecedarian(String s) {
}
return true;
}
-
public static boolean isAbecedarianrec(String s){
- char first = s.charAt(0);
- char second = first ++;
- System.out.println(first);
- System.out.println(second);
- if (s.charAt(0)<second){
- return isAbecedarianrec(s);
+ return isAbecedarianrechelp(s,(char)0);
+ }
+
+ public static boolean isAbecedarianrechelp(String s,char c){
+ if(s.isEmpty()){
+ return true;
+ }else if (c>s.charAt(0)){
+ return false;
+ }else{
+ return isAbecedarianrechelp(s.substring(1),s.charAt(0));
}
-
- return false;
}
public static void main(String[] args) {
- //System.out.println(isAbecedarian("abcde"));
+ System.out.println(isAbecedarian("abcde"));
System.out.println(isAbecedarianrec("abcde"));
}
}
View
BIN captaincrunch.class
Binary file not shown.
View
36 captaincrunch.java
@@ -0,0 +1,36 @@
+public class captaincrunch{
+ public static String encode(String s, int n) {
+ String converted = "";
+ n = n%26;
+ int index = 0;
+
+ while(index < s.length()) {
+ char curChar = s.charAt(index);
+ if ('a' <= curChar && curChar <= 'z' ) {
+ int convertedChar = curChar + n;
+ if (convertedChar > 'z') {
+ convertedChar = (convertedChar - 'z') + 'a' - 1;
+ } else if (convertedChar < 'a') {
+ convertedChar = 'z' - ('a' - convertedChar) + 1;
+ }
+ converted = converted + (char)convertedChar;
+ } else if ('A' <= curChar && curChar <= 'Z' ) {
+ int convertedChar = curChar + n;
+ if (convertedChar > 'Z') {
+ convertedChar = (convertedChar - 'Z') + 'A' - 1;
+ } else if (convertedChar < 'A') {
+ convertedChar = 'Z' - ('A' - convertedChar) + 1;
+ }
+ converted = converted + (char)convertedChar;
+ } else {
+ converted = converted + (char)curChar;
+ }
+ index = index + 1;
+ }
+ return converted;
+ }
+ public static void main(String[] args) {
+ System.out.println(encode("Varun",13));
+ System.out.println(encode("Ineha",-13));
+ }
+}
View
BIN dupledrome.class
Binary file not shown.
View
20 dupledrome.java
@@ -0,0 +1,20 @@
+public class dupledrome{
+ public static boolean isdupledrome(String s){
+ int index = 0;
+ int count = 0;
+ while(index<s.length() -1){
+ if(s.charAt(index) == s.charAt(index+1)){
+ count += 1 ;
+ }
+ index = index + 2;
+ }
+ System.out.println(count);
+ if (count == (s.length()/2)){
+ return true;
+ }
+ return false;
+ }
+ public static void main(String[] args) {
+ System.out.println(isdupledrome("llammaa"));
+ }
+}
View
5 helloprinter.java
@@ -0,0 +1,5 @@
+class helloprinter{
+ public satic void main(String[] args){
+ System.out.println("hello World");
+ }
+}
View
BIN myFistApp.class
Binary file not shown.
View
14 myFistApp.java
@@ -0,0 +1,14 @@
+public class myFistApp{
+ public static void main(String[] args) {
+ int x = 1;
+ while(x<3){
+ System.out.print("Doo");
+ System.out.print("Bee");
+ x = x + 1;
+ }
+ if(x==3){
+ System.out.print("Do");
+ }
+
+ }
+}

0 comments on commit c20957c

Please sign in to comment.
Something went wrong with that request. Please try again.