/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package petzoogarden; import java.util.Arrays; import java.util.Scanner; import java.util.ArrayList; /** * * @author jcmt */ public class PetZooGarden { private enum Denizens {MAMMALS, AMPHIBIANS, REPTILES, BIRDS, INSECTS}; public static void testZoo(PetZoo tempZoo) { int t = tempZoo.getNumAnimals(); System.out.println("Number of animals is "+ tempZoo.getNumAnimals()); System.out.println("Last animal is "+ tempZoo.getOneAnimal(t-1)); System.out.println("Yahoo"); } public static void main( String[] args) { double[] dArray = {8.4, 9.3, 0.2, 7.9, 3.4}; double[] d2Array = new double[dArray.length]; ArrayList dList = new ArrayList(); dList.add("monkey"); dList.add("heffalump"); dList.add(2,"dog"); dList.add(1,"mouse"); System.out.println("String ArrayList is : "); for (String s:dList) { System.out.println(s); } dList.remove(2); dList.remove("monkey"); System.out.println("String ArrayList is : "); for (String s:dList) { System.out.println(s); } System.arraycopy(dArray, 0, d2Array, 0, dArray.length); System.out.printf("\nd2Array: "); for (double v:d2Array) { System.out.printf("%8.2f ", v); } Arrays.sort(dArray); System.out.printf("\ndArray: "); for (double v:dArray) { System.out.printf("%8.2f ", v); } int n = Arrays.binarySearch(d2Array, 2.0); System.out.println(n); } /** * @param args the command line arguments */ /* public static void main(String[] args) { ArrayManipulations A = new ArrayManipulations(); PetZoo jcZoo = new PetZoo(); PetZoo ashZoo = new PetZoo(17, 300.0); PetZoo seanZoo = new PetZoo(ashZoo); Denizens jcDen; jcDen = Denizens.MAMMALS; testZoo(seanZoo); /* * System.out.println("Number of animals is "+ seanZoo.getNumAnimals()); System.out.println("Yahoo"); * **/ /* String[] setAni = {"cow","lamb"}; jcZoo.setAnimals(setAni); jcZoo.setOneAnimal("llama"); jcZoo.setRevenue(-1000); jcZoo.setNumAnimals(33); testZoo(jcZoo); // TODO code application logic here Scanner input = new Scanner( System.in ); int num1, num2, sum; Integer n1, n2; */ /* n1 = 12; System.out.printf("Enter a number: "); num1 = input.nextInt(); System.out.printf("Enter a 2nd number: "); num2 = input.nextInt(); sum = num1; sum += num2; switch(sum % 3) { case 1: System.out.printf("Only, Sum is %d \n", sum); break; case 2: System.out.printf("Sum %d is twice \n", sum); break; case 0: System.out.printf("Sum %d is thrice \n", sum); } System.out.println("Hah!"); int i = 0; while (i < 9) { num1++; num2 *= num2; if (num2 <= 200) { sum = num1 + num2; System.out.println(sum); i++; } } } */ }