Java

AOOP Lab Day 3 (ArrayList,LinkedList,Iterator)

November 21, 2013

Package flower.lib Flower.java package flower.lib;   public class Flower {   public Flower(int p) { this.price = p; }   public Flower() { this.price = 0; }     protected int price;   public void printDetail() { System.out.println("Flower"); }   public int getPrice() { return price; } }package flower.lib; public class Flower { public Flower(int […]

AOOP lab day 2

November 7, 2013

Package flower.lib flower.java package flower.lib;   public class Flower {   public Flower(int p) { this.price = p; }   public Flower() { this.price = 0; }     protected int price;   public void printDetail() { System.out.println("Flower"); }   public int getPrice() { return price; } }package flower.lib; public class Flower { public Flower(int […]

AOOP Lab day 1

October 31, 2013

Flower.java package folwer; public class Flower {   public Flower() {}   public Flower(String fname,int price) { this.fname = fname; this.price = price; }   public String getFname() { return fname; } public void setFname(String fname) { this.fname = fname; } public int getPrice() { return price; } public void setPrice(int price) { this.price = […]

Java Lab Polymorphism

September 12, 2013

package artistdemo;   class Shape { void drow() { System.out.println("Drawing a Shape."); } }   class Rectangle extends Shape { int width,height; Rectangle(int w,int h) { width = w; height = h; } void drow() { System.out.println("Draw a rectangle…width="+width+"height="+height); } }   class Triangle extends Shape { int base,height; Triangle(int b,int h){ base = b; […]

Lab Java 23/07/2556

July 23, 2013

Array lab1 public class LabArray_1 {   public static void main(String[] args) { int[] number = {10,20,30,40,50}; double sum=0; for (int i=0;i<=4;i++) { System.out.println("Score No:"+(i+1)+" >>>>"+number[i]); sum = sum+number[i]; } System.out.println("Sum is "+sum); } }public class LabArray_1 { public static void main(String[] args) { int[] number = {10,20,30,40,50}; double sum=0; for (int i=0;i<=4;i++) { System.out.println("Score […]

Amazing loop (for) in JAVA language

July 16, 2013

หลังจากทีเราพบกับ “Amazing Loop (for) in C language” กันไปแล้ว คราวนี้เรามาพบกับในรูปแบบ Java กันบ้าง ลักษณะคล้ายๆกันครับ import java.util.Scanner; class hearth {   public static void main(String[] args) { for (int a=0;a<2;a++) { System.out.print(" "); if (a != 1) { for (int b=0;b<7;b++) { System.out.print("*"); for (int c=0;c<=b;c++) { System.out.print(" "); } System.out.println("* "); }   }else{ for (int d=0;d<7;d++) […]

Lab Java 11/7/2556

July 11, 2013

Lab Loop /* Kusumoto Lab1 Programming http://kusumoto.co */ import java.util.Scanner; class Lab1 { public static void main(String[] args) { //announce variable int loop; int loop_start; int fac_start; int fac; int time; int time_temp = 1; int time_temp1 = 0; int temp = 0; //input method setup Scanner loop1 = new Scanner (System.in); Scanner fac1 = […]

Lab Java day 3

June 20, 2013

Lab1 import java.util.Scanner; class Lab1 { public static void main(String args[]) { //announce variable String grade_temp; char grade; //setup input method Scanner grade_temp_input = new Scanner (System.in); //show input System.out.print("Enter Grade :: "); grade_temp = grade_temp_input.nextLine(); //convert string to char and uper case grade = grade_temp.toUpperCase().charAt(0); //construction switch (grade) { case ‘A’ : System.out.println("Excallent"); break; […]