다음 BasketTest의 메인 메소드에서 Buyer 클래스 객체 변수의 buy 메소드를 이용하여각각의 제품을 구매한다. 이 때 각 물품은 Product 클래스를 상속받은 Tv, Audio, Computer 클래스의 객체이며 매개변수로 전달된다.만약 buyer의 소지 금액이 모자라면 메시지를 출력하고 물품을 구매하지 않고돈이 충분하다면 돈을 제하고 구매를 한다. 이 물품은 카트에 담긴다.카트에 들어가는 제품은 3개로 초기화되고 용량이 부족해지면 2배로 용량을 늘린다. public class BasketTest {public static void main(String arg[]) {Buyer b = new Buyer();b.buy(new Tv());b.buy(new Computer());b.buy(new ..
1. 은행은 계좌를 관리한다.2. 은행은 계좌를 등록한다. 3. 은행은 계좌번호로 계좌를 찾을 수 있다.4. 은행은 계좌의 소유자명으로 계좌를 찾을 수 있다.5. 은행은 모든 계좌의 목록을 볼 수 있다. 6. 계좌는 소유자명, 계좌번호, 잔고로 구성된다.7. 계좌는 입금,출금 기능과 잔고확인 기능이 있다.8. 계좌에서 잔고의 변화가 있을 때마다 거래내역에 기록된다.9. 거래내역은 거래일자, 거래시간, 계좌번호, 입금/출금여부, 거래금액, 은행명으로 구성된다. 기타 부수적인 변수와 메소드는 생략하였다. 다음은 실제 자바 코드이다. BankUI.java import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamRead..
오라클 DBMS 설치 (window, PC용) 자바 UI 관련 실습 조금 ...
새로운 객체를 할당하고 이를 다른 참조변수에 복사하는 경우에 대해 알아본다.결과적으로는 참조변수에 기존의 객체를 참조하는 참조변수를 대입하면 그 두 변수는 동일한 것을 가리킨다.그리고 값이 똑같다고 객체까지 같다고 할 수는 없다. public class ObjectTest {int data; public ObjectTest(int x) {data = x;} public ObjectTest clone() throws CloneNotSupportedException {ObjectTest temp = new ObjectTest(this.data);return temp;} public static void main(String[] args) {// TODO Auto-generated method stubObje..
Assertion은 예외처리의 한 가지 방법으로 코드의 논리적오류를 검사한다. import java.io.BufferedReader;import java.io.InputStreamReader; public class AssertionTest { public static void main(String[] args) {// TODO Auto-generated method stubint a; BufferedReader in = new BufferedReader(new InputStreamReader(System.in));try {System.out.println("점수를 입력하세요");a = Integer.parseInt(in.readLine());assert (a =0) : "올바르지 못..
Exception 클래스를 상속받는 사용자 예외 클래스 작성예외 발생 시 예외를 새로운 객체에 던짐 import java.io.BufferedReader;import java.io.InputStreamReader; public class UserException {public static void main(String arg[]) {BufferedReader in = new BufferedReader(new InputStreamReader(System.in));try {System.out.println("하나의 숫자를 입력하세요 ");int score = Integer.parseInt(in.readLine());if (score < 0) {throw new UserException1("점수가 너무 작음"..
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html 에서Oracle Database 11g Release 2 / (11.2.0.1.0) / Microsoft Windows (32-bit) / 파일 2 개 다운로드다운로드한 2 개의 파일에서 \database\stage\Components 경로 내에 있는 파일 통합 (3개 파일) 설치 후 cmd -> sqlplus -> system/password 로 로그인. 혹은 sqlplus "/as sysdba" 로 로그인(관리자) 관리자 암호 잃어버린 경우command에서 관리자모드로 로그인 후 alter user system identified by 암호; scott ..
try-catch와 throw public class ThrowsException { static int a, b; public static void main(String[] args) {// TODO Auto-generated method stub try {a = Integer.parseInt("12");b = Integer.parseInt("0");method1();} catch (ArithmeticException e) {System.out.println("ArithmeticException 처리 루틴 : ");System.out.println(e + " 예외 발생");} catch (NumberFormatException e) {System.out.println("NumberFormatExcept..
- Total
- Today
- Yesterday
- 배열
- 알고리즘
- 클래스
- 게임
- ERP
- 데이터베이스
- 졸업작품
- 정보
- 안드로이드
- 자바스크립트
- 충북대
- 자바
- 잡담
- jsp
- HTML
- 메모장
- 이론
- 도전과제
- 소켓
- 오라클
- 아두이노
- 파이썬
- JQuery
- 정렬
- SVN
- SQL
- 청주
- db
- 프로젝트
- CSS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |