본문 바로가기

Programming129

자바 기말 플젝 코드(미완성) 2020. 12. 30.
입출력 스트림과 파일 입출력 명품자바프로그래밍 Chapter8_Lab07 실습1| 연락처 정보 저장 및 출력 ( PhoneSave.java, PhoneOpen.java) import java.io.*; import java.util.*; public class PhoneSave { public static void main(String[] args) { Scanner scan = new Scanner(System.in); FileWriter fout = null; //FileWriter 초기화 try { fout = new FileWriter("c:\\temp\\phone.txt"); //파일과 연결된 출력 문자 스트림 생성 System.out.println("전화번호 입력 프로그램입니다."); while(true) { //그만을 .. 2020. 10. 16.
제너릭과 컬렉션 명품자바프로그래밍 Chapter7_Lab06 실습1| Vector 실습 import java.util.Scanner; import java.util.Vector; public class VectorTest { public static void PrintV(Vector v) { //삭제전, 후 Vector 출력 System.out.print("["); //[ 출력 for(int i = 0; i 없는 도시 System.out.println(city + "는 없는 도시입니다."); else //lo 가 있을 경우 --> 있는 도시 System.out.println(lo.getCity() + "\t" + lo.getLongitude() + "\t" + lo.getLatitude()); } scan.close().. 2020. 10. 16.
패키지 개념과 자바 기본 패키지 명품자바프로그래밍 Chapter6_Lab05 실습2| Circle 클래스 작성 public class Circle { private int x; private int y; private int radius; Circle(int x, int y, int radius) { // 3개의 인자를 받아 생성자 생성해 필드를 초기화 this.x = x; this.y = y; this.radius = radius; } @Override public String toString() { //toString()은 출력 결과에 맞게 재정의한다. return "Circle (" + x + "," + y + ") 반지름" + radius; } //Object 클래스 : 모든 클래스의 수퍼 클래스 public boolean eq.. 2020. 10. 16.
상속 명품자바프로그래밍 Chapter5_Lab04 + 교재 외 실습 1|고객 클래스 만들기(Person.java,Customer.java) - 재정의 연습예제 public class Person { private String name; //이름 속성 private String address; //주소 속성 private String phone; //전화번호 속성 //일반 01012345678형태가 int의 범위 밖이라는 오류! -> String으로 함 public Person(String name, String address, String phone) { //생성자 this.name = name; this.address = address; this.phone = phone; } public String get.. 2020. 10. 16.
클래스와 객체 명품자바프로그래밍 Chapter4_Lab03 실습2 | Grade 클래스 작성 import java.util.Scanner; public class Grade { private int math; //멤버 변수 선언 private int science; private int english; public Grade(int m,int s, int e) { //생성자 메소드 작성 this.math = m; // 매개변수 받아 멤버 변수에 저장 this.science = s; this.english = e; } public int average() { //세과목의 평균을 리턴하는 average() 메소드 작성 return (math + science + english) /3; } public static void.. 2020. 10. 16.