Lab7

Lab7 프로젝트 디렉토리 안에 모든 파일(src/*.java & bin/*.class)와 보고서 (장수제한없음)를 넣고 JAVA20-2_Lab7_학번_이름.zip 압축한 후 제출 (due by 11/9)

java2-lab7

week10-lab7 동영상을 참고하세요.

Strategy vs Command

https://stackoverflow.com/questions/4834979/difference-between-strategy-pattern-and-command-pattern

Typically the Command pattern is used to make an object out of what needs to be done — to take an operation and its arguments and wrap them up in an object to be logged, held for undo, sent to a remote site, etc. There will tend to be a large number of distinct Command objects that pass through a given point in a system over time, and the Command objects will hold varying parameters describing the operation requested.

The Strategy pattern, on the other hand, is used to specify how something should be done, and plugs into a larger object or method to provide a specific algorithm. A Strategy for sorting might be a merge sort, might be an insertion sort, or perhaps something more complex like only using merge sort if the list is larger than some minimum size. Strategy objects are rarely subjected to the sort of mass shuffling about that Command objects are, instead often being used for configuration or tuning purposes.

Both patterns involve factoring the code and possibly parameters for individual operations out of the original class that contained them into another object to provide for independent variability. The differences are in the use cases encountered in practice and the intent behind each pattern.

Midterm Extra

중간고사 문제를 다시 풀어본다. (Due by 11/2)
중간고사 예제 + 문제풀이 보고서 제출 (제출하면 +10점. 중간점수 없음)
Midterm_학번_이름.zip 압축한 후 e-learning으로 제출
보고서는 출력해서 수업시간에 제출한다.

Lab6

Lab6 프로젝트 디렉토리 안에 모든 파일(src/*.java & bin/*.class)와 보고서 (3~4장)를 넣고 JAVA20-2_Lab6_학번_이름.zip 압축한 후 제출 (due by 11/2)

Singleton Pattern – 5가지 구현방법
1. classic implementation
2. thread-safe using synchronized keyword
3. thread-safe using eager initialization
4. thread-safe using lazy initialization with double checked locking
5. thread-safe using inner static class

중간고사이후 대면강의 시작

안녕하세요.
자바2 수업은 현재 수강생이 21명으로 병행강의방식에 해당됩니다.
해당 교과목별 해당 권장학년 기준 1,2학년은 홀수주차에 대면으로 수업을 하고 짝수 주차는 온라인 강의로 진행합니다.
중간고사 실시후 9주(10/27), 11주(11/10), 13주차(11/24), 15주차(12/8) 대면수업하겠습니다. (“2020-2학기 학부 수업 강의실 배정 방법 안내(8/24)” 공문의 내용 및 붙임의 요일별 주차에 대한 달력표기를 기준으로)

Midterm

자바2 중간고사 실습문제

범위: 처음부터 – 배운데까지 (팩토리패턴)

일시: 10/20 (화) 1:30-3:30

장소: 2공 521호

UserInput


public class UserInput {
	static Scanner input = new Scanner(System.in);

	public static double getDouble() {
		double value;
    	while(true) { // while
    		try {
    			value = input.nextDouble();
    			break;
    		}
    		catch (Exception e) {
    			System.out.print("Error! Please re-enter double value: ");
    			input.next();
    		}
    	}
		input.nextLine();
        return value;
	}

	public static int getIntegerBetween(int min, int max) {
		int value = 0;
    	do { // do-while
    		System.out.printf("Enter the number between [%d - %d]", min, max);
    		try {
    			value = input.nextInt();
    		}
    		catch (Exception e) {
    			System.out.println("Error! Please re-enter integer value");
    			input.next();
    			continue;
    		}
    	} while(value < min || value > max);
    	return value;
	}
	
	public static boolean getUserExitKey()
    {
    	System.out.println("Press q-key to quit the program or enter-key to exit the program");
		String s = input.nextLine();
        if (s.contentEquals("q")) {
            return true;
        }
        else {
            return false;
        }
    }
}