truu tuong
package com.abstraction;
public abstract class Shape {
//dien tich
public abstract Double getArea();
//chu vi
public abstract Double getPermeter();
public void displaySharpCategory()
{
System.out.println("These : Circlse,");
}
}
package com.abstraction;
public class Ractangle extends Shape {
@Override
public Double getArea() {
// TODO Auto-generated method stub
return Double.parseDouble("4000");
}
@Override
public Double getPermeter() {
// TODO Auto-generated method stub
return Double.parseDouble("400");
}
}
package com.abstraction;
public class Circle extends Shape {
@Override
public Double getArea() {
// TODO Auto-generated method stub
return Double.valueOf("1000");
}
@Override
public Double getPermeter() {
// TODO Auto-generated method stub
return Double.valueOf("100");
}
}
Circle cl=new Circle();
// System.out.println("Dieen tich la:"+cl.getArea());
// //c2
// Shape sh=new Circle();
// System.out.println("Dien tich laf :"+sh.getArea());
//
// //c3
// sh=new Ractangle();
// System.out.println("Dien tich laf :"+sh.getArea());
// sh.displaySharpCategory();
2013/11/20 Vu Tung Lam <vutunglampro@gmail.com>
package com.puple;public class Emloyyee {String name;public String getName() {return name;}public void setName(String name) {this.name = name;}public String getMobile() {return mobile;}public void setMobile(String mobile) {this.mobile = mobile;}String mobile;public Emloyyee(String name, String mobile) {public Emloyyee() {super();}}package com.puple;public class Course {String idCourse;String nameCourse;public String getIdCourse() {return idCourse;}public void setIdCourse(String idCourse) {this.idCourse = idCourse;}public String getNameCourse() {return nameCourse;}public void setNameCourse(String nameCourse) {this.nameCourse = nameCourse;}public Course(String idCourse, String nameCourse) {super();this.idCourse = idCourse;this.nameCourse = nameCourse;}public Course() {super();}}package com.main;import java.util.ArrayList;import java.util.LinkedList;import java.util.ListIterator;import javax.swing.plaf.SliderUI;import com.puple.Course;import com.puple.Emloyyee;public class FormMain {/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubThread newThr1=new Thread(doCourse);newThr1.start();Thread newThr2=new Thread(doEmloyyee);newThr2.start();}private static Runnable doEmloyyee=new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep(3000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}ArrayList<Emloyyee> listEmloyee=new ArrayList<Emloyyee>();listEmloyee.add(new Emloyyee("khoat", "012344"));listEmloyee.add(new Emloyyee("Huy", "0124434"));listEmloyee.add(new Emloyyee("Duong", "63636535"));listEmloyee.add(new Emloyyee("khuyen", "3242424"));listEmloyee.add(new Emloyyee("Tuan", "45325454"));System.out.println("Danh sach sinh vien la");int d=1;for (Emloyyee em : listEmloyee) {System.out.print(em.getName()+"\t");System.out.println("So dien thoai nhan vien la "+d+" :"+em.getMobile());}}};private static Runnable doCourse=new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubArrayList<Course> listCourse=new ArrayList<Course>();listCourse.add(new Course("id01", "tk72"));listCourse.add(new Course("id02", "tk71"));listCourse.add(new Course("id03", "tk73"));listCourse.add(new Course("id04", "tk74"));listCourse.add(new Course("id05", "tk75"));System.out.println("Danh sach lop hoc la:");int d=1;for (Course em : listCourse) {System.out.print("Ma id :"+em.getIdCourse()+"\t");System.out.println("Ten lop hoc la: "+em.getNameCourse());}}};private static Runnable linkCourse=new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubtry {Thread.sleep(1000);} catch (InterruptedException e) {// TODO Auto-generated catch blocke.printStackTrace();}LinkedList<Course> listLink=new LinkedList<Course>();listLink.add(new Course("linkid01", "tk72"));listLink.add(new Course("linkid01", "tk72"));listLink.add(new Course("linkid01", "tk72"));listLink.add(new Course("linkid01", "tk72"));ListIterator iter=listLink.listIterator();while(iter.hasNext()){System.out.println(iter.next());}}};}On Wed, Nov 20, 2013 at 7:17 PM, Vu Tung Lam <vutunglampro@gmail.com> wrote:
package com.main2;public class Employee {private String name;public String getName() {return name;}public void setName(String name) {this.name = name;}private String mobile;public String getMobile() {return mobile;}public void setMobile(String mobile) {this.mobile = mobile;}public Employee(String name, String mobile) {super();this.name = name;this.mobile = mobile;}}package com.main;import java.awt.List;import java.util.ArrayList;import com.main2.Employee;
public class mainform {public static void main(String[] args){ArrayList<Employee> listemployee=new ArrayList<Employee>();listemployee.add(new Employee("khoat duong", "01232321"));listemployee.add(new Employee("khoat duong1", "01232322"));listemployee.add(new Employee("khoat duong2", "01232323"));listemployee.add(new Employee("khoat duong3", "01232324"));listemployee.add(new Employee("khoat duong4", "01232325"));listemployee.add(new Employee("khoat duong5", "01232326"));listemployee.add(new Employee("khoat duong6", "01232327"));listemployee.add(new Employee("khoat duong7", "01232328"));listemployee.add(new Employee("khoat duong8", "01232329"));listemployee.add(new Employee("khoat duong9", "012323222"));listemployee.add(new Employee("khoat duong10", "01232322"));for (Employee em : listemployee) {System.out.println(em.getName()+"-"+em.getMobile());}}}On Wed, Nov 20, 2013 at 6:57 PM, Vu Tung Lam <vutunglampro@gmail.com> wrote:
package com.main;import java.util.ArrayList;public class mainform {/*** @param args*/public static void main(String[] args) {// TODO Auto-generated method stubThread newth=new Thread(doSomeThing);newth.start();ArrayList<String> namelist;namelist=new ArrayList<>();namelist.add("sdff");namelist.add("adfaf");namelist.add("adfasdf");for (String k : namelist) {System.out.println(k);}namelist.remove(1);for (String k : namelist) {System.out.println(k);}}private static Runnable doSomeThing =new Runnable() {@Overridepublic void run() {// TODO Auto-generated method stubfor (int i = 0; i < 300; i++) {System.out.print("dday la rieng");}}};}On Wed, Nov 20, 2013 at 5:14 PM, Dương Văn Khoát <webboyk@gmail.com> wrote:
package Inet;import java.io.InputStreamReader;import java.util.Scanner;public class baisonguyen {/*** @param args*/static int countPhanTu;static int []mang;public static void main(String[] args) {// TODO Auto-generated method stubScanner scan=new Scanner(new InputStreamReader(System.in));System.out.println("Nhap so phan tu:");countPhanTu=scan.nextInt();mang=new int[countPhanTu];System.out.println("Nhap vao cac gia tri cho phan tu:");for(int i=0;i<countPhanTu;i++){System.out.print("mang["+i+"]=");mang[i]=scan.nextInt();}System.out.println();System.out.println();System.out.println();System.out.println();System.out.println();System.out.println("---------------------------------------");System.out.println("Menu");System.out.println("Nhap T truy suat pt");System.out.println("Nhap N de them 1 so pt");System.out.println("Nhap X de xoa 1 phan tu");System.out.println("Nhap L de liet ke");System.out.println("Nhap TK de tim kiem");System.out.println("Nhap S de sap xep");System.out.println("Nhap E de thoat chuong trinh");while(true){String strMenu=scan.nextLine().toUpperCase();switch (strMenu) {case "T":System.out.print("Nhap vi tri pt can truy suat :");int intSelec=scan.nextInt();truyxuatphantu(intSelec);System.out.print("Nhap cac phim de tiep tuc ");break;case "N":System.out.print("Nhap pt can them :");int intadd=scan.nextInt();themmotpt(intadd);System.out.print("Nhap cac phim de tiep tuc ");break;case "X":System.out.print("Nhap vi pt ca xoa :");int intxoa=scan.nextInt();xoaphantuthui(intxoa);break;case "L":break;case "TK":break;case "S":break;case "E":break;}}}public static void truyxuatphantu(int i){System.out.println("phan tu thu "+i+" cua mang la "+mang[i]);}public static void xoaphantuthui(int i){int []tmp=new int[mang.length-1];if(i==0){for (int j = 0; j < tmp.length; j++) {tmp[j]=mang[j+1];}}else if(i==mang.length-1){for (int j = 0; j < tmp.length; j++) {tmp[j]=mang[j];}}else{for (int j = 0; j < tmp.length; j++) {if(j<i){tmp[j]=mang[j];}else if(j>=i){tmp[j]=mang[j+1];}}}System.out.println("mang sau khi xoa phan tu thuw "+i+" la:");for (int j = 0; j < tmp.length; j++) {System.out.print(tmp[j]+" ");}}public static void themmotpt(int a){int []m=new int[mang.length+1];for (int i = 0; i < mang.length; i++) {m[i]=mang[i];}m[mang.length]=a;System.out.println("mang sau khi them phan tu "+a+" la:");for (int j = 0; j < m.length; j++) {System.out.print(m[j]+" ");}}}
Không có nhận xét nào:
Đăng nhận xét