class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

Similar documents
gnu-lee-oop-kor-lec06-3-chap7

PowerPoint 프레젠테이션

쉽게 풀어쓴 C 프로그래밍

C프로-3장c03逞풚

JAVA PROGRAMMING 실습 08.다형성

C++ Programming

Microsoft PowerPoint - Java7.pptx

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

05-class.key

PowerPoint Presentation

C++ Programming

Microsoft PowerPoint - [2009] 02.pptx

PowerPoint Presentation

PowerPoint Presentation

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

Microsoft PowerPoint - 2강

Design Issues

PowerPoint Presentation

쉽게 풀어쓴 C 프로그래밍

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

untitled

슬라이드 1

chap10.PDF

PowerPoint Presentation

자바 프로그래밍

080629_CFP °ø°³¿ë.hwp

PowerPoint Presentation

쉽게 풀어쓴 C 프로그래밍

02 C h a p t e r Java

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - C++ 5 .pptx

PowerPoint Presentation

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - Chapter 6.ppt

K&R2 Reference Manual 번역본

쉽게 풀어쓴 C 프로그래밍

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

PowerPoint Presentation

Microsoft PowerPoint - 8ÀÏ°_Æ÷ÀÎÅÍ.ppt

(Microsoft PowerPoint - 07\300\345.ppt [\310\243\310\257 \270\360\265\345])

비긴쿡-자바 00앞부속

3. 1 포인터란 3. 2 포인터변수의선언과사용 3. 3 다차원포인터변수의선언과사용 3. 4 주소의가감산 3. 5 함수포인터

Java

설계란 무엇인가?

설계란 무엇인가?

1. auto_ptr 다음프로그램의문제점은무엇인가? void func(void) int *p = new int; cout << " 양수입력 : "; cin >> *p; if (*p <= 0) cout << " 양수를입력해야합니다 " << endl; return; 동적할

Spring Boot/JDBC JdbcTemplate/CRUD 예제

PowerPoint 프레젠테이션

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

JAVA PROGRAMMING 실습 05. 객체의 활용

int main(void) int a; int b; a=3; b=a+5; printf("a : %d \n", a); printf("b : %d \n", b); a b 3 a a+5 b &a(12ff60) &b(12ff54) 3 a 8 b printf(" a : %x \

(Microsoft PowerPoint - 11\300\345.ppt [\310\243\310\257 \270\360\265\345])

PowerPoint Presentation

Cluster management software

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

The C++ Programming Language 4 장타입과선언 4.11 연습문제 Hello,world! 프로그램을실행시킨다. 프로그램이컴파일되지않으면 B3.1 을참고하자. #include<iostream> //#include 문, 헤더파일, 전처리지시

PowerPoint Presentation

rmi_박준용_final.PDF

쉽게 풀어쓴 C 프로그래밍

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

TEST BANK & SOLUTION

슬라이드 1

JAVA PROGRAMMING 실습 02. 표준 입출력

5장.key

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

PowerPoint Template

Microsoft PowerPoint - additional06.ppt [호환 모드]

Spring Boot

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

슬라이드 1

Microsoft PowerPoint - 03-TCP Programming.ppt

Microsoft PowerPoint - Chapter 1-rev

PowerPoint Presentation

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074>

C++ Programming

07 자바의 다양한 클래스.key

PowerPoint Template

Microsoft PowerPoint - 13_UMLCoding(2010).pptx

PowerPoint Template

Interstage5 SOAP서비스 설정 가이드

untitled

gnu-lee-oop-kor-lec10-1-chap10

윤성우의 열혈 TCP/IP 소켓 프로그래밍

PowerPoint Presentation

Java ...

PowerPoint 프레젠테이션

Microsoft PowerPoint - 04-UDP Programming.ppt

Network Programming

1. 기본형의형변환복습 C/C++ 형변환의종류 자동형변환 ( 묵시적형변환 ) 강제형변환 ( 명시적형변환 ) 기본형의자동형변환의예 1. 배열 to 포인터변환 배열명은해당배열의첫번째원소의 주소로변환됨 int ary[10]; int *pary = ary; 2. 함수 to 포

12-file.key

JAVA PROGRAMMING 실습 05. 객체의 활용

Modern Javascript

C++ Programming

Microsoft Word - java19-1-midterm-answer.doc

09-interface.key

1. 클래스와배열 int 형배열선언및초기화 int ary[5] = 1, 2, 3, 4, 5 ; for (int i = 0; i < 5; i++) cout << "ary[" << i << "] = " << ary[i] << endl; 5 장클래스의활용 1

Spring Data JPA Many To Many 양방향 관계 예제

JAVA PROGRAMMING 실습 02. 표준 입출력

JUNIT 실습및발표

Transcription:

Level 1은객관식사지선다형으로출제예정 1. 다음은 POST(Post of Sales Terminal) 시스템의한콜레보레이션다이어그램이다. POST 객체의 enteritem(upc, qty) 와 Sale 객체의 makellineitem(spec,qty) 를 Java 또는 C ++, C # 언어로구현하시오. 각메소드구현과관련하여각객체내에필요한선언이있으면선언하시오. 정답 : (Java & C#) public class POST public void enteritem(int upc, int qty) ProductCatalog prodcatalog; ProductSpecification spec = prodcatalog.specification(upc); public class Sale void makelineitem(productspecification spec, int qty) SalesLineItem sl = new SalesLineItem(spec, qty); (C++) class POST void enteritem(int upc, int qty) ProductCatalog* prodcatalog; ProductSpecification* spec = prodcatalog->specification(upc); ; 1

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++, C # 언어로구현하시오. trianglearea:=triangle.calculatearea( ) circlearea:= circle.calculatearea( ) [trianglearea< circlearea] [trianglearea>= circlearea] System.out.printIn( Circle is Bigger! ) System.out.printIn( Triangle is Bigger! ) return circlearea return trianglearea 정답 : (java) 해당클래스의특정메소드부분을구현한것이다. Circle 클래스와 Triangle 클래스의구현은달라질수있으며 Foo 클래스의 calculatemaxarea의 if문에대한구현을정확하게표현해야한다. // 아래의소스에서 Bold체에만해당됨 public class Foo public double calculatemaxarea(triangle triangle, Circle circle) double trianglearea = triangle.calculatearea(); double circlearea = circle.calculatearea(); if(trianglearea>= circlearea) System.out.printIn( Triangle is Bigger! ); return trianglearea; else if(trianglearea< circlearea) System.out.printIn( Circle is Bigger! ); 2

return circlearea KCSM Level 1 Sample 문제 public class Circle public double radius = 5.0; public double calculatearea() return radius* radius*3.14; public class Triangle public int height = 10; public int width = 10; public double calculatearea() return height * width *0.5; (C++) // 아래의소스에서 Bold 체에만해당됨 class CCircle double radius = 5.0; double calculatearea(); class CTriangle int height = 10; int width = 10; double calculatearea(); class CFoo double calculatemaxarea(ctriangle triangle, CCircle circle); double CCircle::calculateArea() return radius * radius * 3.14; 3

double CTriangle::calculateArea() return height * width * 0.5; double CFoo::calculateMaxArea(CTriangle triangle, CCircle circle) double trianglearea = triangle.calculatearea(); double circlearea = circle.calculatearea(); if(trianglearea >= circlearea) printf("triangle is Bigger!\n"); return trianglearea; else if(trianglearea < circlearea) printf("circle is Bigger!\n"); return circlearea; (C#) // 아래의소스에서 Bold 체에만해당됨 namespace anamespace public class CCircle public double radius = 5.0; public double calculatearea() return radius * radius * 3.14; public class CTriangle public int height = 10; public int width = 10; public double calculatearea() return height * width * 0.5; public class CFoo double calculatemaxarea(ctriangle triangle, CCircle circle) double trianglearea = triangle.calculatearea(); double circlearea = circle.calculatearea(); if(trianglearea >= circlearea) Console.WriteLine("Triangle is Bigger!"); return trianglearea; else if(trianglearea < circlearea) Console.WriteLine("Circle is Bigger!"); return circlearea; 4

KCSM Level 1 Sample 문제 3. 다음코드를보고액티비티 (Activity) 다이어그램을작성하시오. [ 자바버전 ] import javax.swing.joptionpane; class TestCalculator public static void main(string[] args) String number1 = JOptionPane.showInputDialog( First Num: ); String number2 = JOptionPane.showInputDialog( Second Num: ); double num1 = Double.parseDouble(number1); double num2 = Double.parseDouble(number2); int answer = JOptionPane.showConfirmDialog(null, Add the numbers?, Calculator, JOptionPane.YES_NO_OPTION); Calculator calcus = new Calculator(num1, num2); double calculatedanswer; char operator; if (answer == JOptionPane.YES_OPTION) calculatedanswer = calcus.calculatesum(); operator = + ; else calculatedanswer = calcus.calculatedouble(); operator = - ; String result = Our Calculation: + calcus.getnumber1() + + operator + calcus.getnumber2(); result += \nthe answer is + calculatedanswer; JOptionPane.showMessageDialog(null, result); Sytem.exit(0); [C++ 버전 ] #include <iostream> using namespace std; void main(void) const char YES_OPTION = 'Y'; char oper; int result; 5

char number1[10]; char number2[10]; char answer; int num1; int num2; KCSM Level 1 Sample 문제 cin >> number1; cin >> number2; num1 = atoi(number1); num2 = atoi(number2); Caculator calcus = new Calculator(number1, number1); cout << "Add the numbers(y/n)?"; cin >> answer; if(answer!= YES_OPTION) result = calcus.claculatedifference(); oper = '-'; else result = clacus.calculatesum(); oper = '+'; printf("our Calculation: %d %c %d = %d", num1, oper, num2, result); [C# 버전 ] using System; class Calculator [STAThread] static void Main(string[] args) const string YES_OPTION = "Y"; string oper = ""; string result; string answer; string number1 = Console.ReadLine(); 6

Level 1은객관식사지선다형으로출제예정 string number2 = Console.ReadLine(); int num1 = int.parse(number1); int num2 = int.parse(number2); Caculator calcus = new Calculator(num1, num2); Console.WriteLine("Add the numbers(y/n)?"); answer = Console.ReadLine(); if(answer!= YES_OPTION) result = calcus.claculatedifference(); oper = "-"; else result = calcus.calculatesum(); oper = "+"; Console.WriteLine("Our Calculation: 0 1 2 = 3", num1, oper, num2, result); 정답 : 7