rCan - 당신의 행복이 바로 저의 행복입니다. -
   rCan - 당신의 행복이 바로 저의 행복입니다.  
Front Page
| Guestbook | Admin   
 
2008/12/28 19:50 2008/12/28 19:50
[2008.12.29] Java 간단한 클래스 제작

import java.io.*;

public class Exam_02{
 public static void main(String[] arg) throws NumberFormatException, IOException{
  int num=0;
  String str=null;
  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 
  System.out.println("관리할 컴퓨터의 개수를 입력하여주세요 : ");
 
  num=Integer.parseInt(in.readLine());
   
  ComputerManager cm = new ComputerManager(num);
 
  while(true){
   System.out.print("0.프로그램종료\n1.컴퓨터정보입력\n2.컴퓨터정보보기(선택)\n3.모든컴퓨터정보보기\n입력 : ");
   num=Integer.parseInt(in.readLine());
   
   switch(num){
   case 0:
    System.out.print("프로그램을 종료하겠습니다");
    return;
   case 1:
    System.out.print("컴퓨터 번호를 입력하세요 : ");
    num=Integer.parseInt(in.readLine());
    System.out.print("컴퓨터 이름을 입력하세요 : ");
    str=in.readLine();    
    cm.ComputerInputData(num,str);
    break;    
   case 2:
    System.out.print("조회하실 컴퓨터 번호를 입력해주세요 :");
    num=Integer.parseInt(in.readLine());
    cm.ComputerView(num);
    break;
   case 3:
    cm.ComputerView();
    break;
   default: System.out.println("해당하는 메뉴는 없습니다");
   
   }
  } 
 }
}
class ComputerManager{
 private int maxNum,numCnt;
 private Computer com[];
 
 public ComputerManager(int num) {
  // TODO Auto-generated constructor stub
  this.numCnt=0;
  this.maxNum=num;
 
  com=new Computer[num];
 
  for(int i=0;i<num;i++)
   com[i]= new Computer();
 
 }
 
 
 public void ComputerInputData(int num, String str) {
  com[numCnt].setIdName(str);
  com[numCnt].setIdNum(num);  
 }

 public void ComputerView(){
  for(int i=0;i<maxNum;i++)
   System.out.format("컴퓨터 번호 : %d\n컴퓨터 이름 : %s\n",com[i].getIdNum(),com[i].getIdName());
 }
 public void ComputerView(int idNum){
  for(int i=0;i<maxNum;i++)
   if(idNum==com[i].getIdNum()){
    System.out.format("컴퓨터 번호 : %d\n컴퓨터 이름 : %s\n",com[i].getIdNum(),com[i].getIdName());
    return;
   }
  System.out.println("해당하는 컴퓨터 번호를 찾을수 없습니다 ");
 
 }
 
 
}
class Computer{
 private int idNum;
 private String idName;
 
 public Computer(){
  idNum=0;
  idName="Noname";
 }
 public String getIdName() {
  return idName;
 }
 public int getIdNum() {
  return idNum;
 }
 public void setIdName(String idName) {
  this.idName = idName;
 }
 public void setIdNum(int idNum) {
  this.idNum = idNum;
 }
}



BLOG main image
오오!! 타마키군~~♡
 Notice
[이력서] 기본내용
 Category
전체 (424)
Daily (367)
Story (11)
Study (34)
For Trackback (12)
 Recent Entries
[2008.12.29] Java 간단한...
[Java]
[ATMEGA128] 레포트
[ATMEGA128] 시험관련
[게임제작] 기말고사
 Recent Comments
뷁끼!
용용 - 2008
^_^/ 즐거운 한해가
rCan - 2008
새해 복 많이 받고, 2008...
누나 - 2008
'_'
kyj - 2007
집에 있겠지
rCan - 2007
 TAGS
UDMA 호러영화 L2캐쉬 뱅크 HyperThreading 젠더 Ethernet Adapter EIDE Topology PipeLine Dual Processor PCI Express MBchipset Syper Scalar File System wildcard-mask Cable SMTP HDD Cluster 양면 cost POP3 AGP IMAP 금연 FSB 셀러론 Dual Core access-list 영화관 매너 TCP/IP RDRAM 슬롯 IDE CPU 데슈츠 PCI 단면 Slack VESA RAM
 Link Site
CS : 리브레또
CS : 세륜중학교 3학년 6반
CS : 우리반까페
DP : Eclipse download
DP : Java JDK1.4 LInks
GS : 마비노기
GS : 일본한게임 마작
IS : Cisco
IS : ICBANK
IS : KLDP
IS : MobileJava
IS : PHP스쿨
IS : Winbbs
IS : 데이타시트
IS : 로맨스 소설
IS : 메가박스 상영시간표
IS : 소설
IS : 숭실 전산원
IS : 인터넷속도 태스트
IS : 자바스터디
IS : 자바패턴
PS : 겔겔군
PS : 고청심교수님
PS : 김성채선생님
PS : 김승태
PS : 도창수
PS : 오탄코나스
PS : 전병우
SS : 아시아배터리
태터툴즈 배너
 
<< 2009 >> JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
July 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31