본문 바로가기

분류 전체보기

(92)
Playgrounds '플레이그라운드' 17. '코드'let  상수를 정의 하여  world.place ( expert, atColumn:1,row:1)  캐릭터 위치를 지정해줍니다. func 사용하여 함수를 정의 합니다. let expert = Expert()world.place(expert, atColumn:2, row: 6)func turnAround() {expert.turnLeft()expert.turnLeft()}func turnLockCollectGem() {expert.turnLeft()expert.turnLockUp()turnAround()expert.moveForward()expert.collectGem()turnAround()expert.moveForward()expert.turnRight()}turnLockCollectGem()..
Button '버튼' 클릭 함수 코딩. '소스파일 열고 코딩' Lebel  =  레이블 = 노랑색Text Field  = 텍스트 필드 = 주황색Button = 버튼= 초록색스토리보드 와 소스창을 열어서 제목을 설정하고 연동합니다.Button '버튼' 클릭 시 동작 구현하기 위해서  Button  = 초록색A.text="Name"+B.text! 코드를 입력 합니다.Label = A = 노랑색Text Field = B = 주황색A.text="Hello"+B.text!코드 완성 후 버튼을 클릭하면 Lebel / Hello 문장이 로딩되고,텍스트 필드에 글자를 입력하면 Hello-안녕하세요 문장이 로딩 됩니다.
Label '레이블' , Text Field '텍스트 필드' Button '버튼' 스토리보드,소스 연동 흰색 동그라미 표시부분을 클릭하면 Assistant ' 소스 창이 나옵니다.왼쪽 스토리보드 , 오른쪽 소스 영역입니다.Label '레이블' 노란색Text Field '텍스트 필드' 초록색Button '버튼' 파랑색키보드의 control 누른 상태에서 소스창에 드래그 합니다.텍스트를 더블 클릭하면 글자를 입력할수 있습니다.'연결선이 나타나면 이 연결선을 뷰 컨트롤러 (ViewController)의 클래스 선언문 바로 아래에 끌어다 놓으세요.아웃렛 변수는 일반적으로 클래스(class) 선언부 바로 아래에 추가합니다.
Playgrounds '플레이그라운드' 16. '코드'목표: 함수를 작성하여 특정 횟수만큼 앞으로 이동해보세요.let expert = Expertfunc move (distance: Int) {}move(distance:숫자)let expert = Expert()func move (distance: Int) {for i in 1 ... distance {expert.moveForward()}move(distance: 6)expert.turnRight()move(distance:2)expert.turnRight()move(distance:5)expert.turnLeft()move(distance:5)expert.turnLeft()expert.turnLockUp()expert.turnLeft()move(distance:3)expert.turnRight(..
Playgrounds '플레이그라운드' 15. '코드'반복 패턴의 함수를 정의해 보세요.func [반복 사용 가능한 명칭을 입력해주세요] () {[                                         ]}[                                          ][                                          ] func [go]() {turnLeft()}moveForward()collectGem()moveForward()toggleSwitch()moveForward()go()moveForward()collectGem()moveForward()toggleSwitch()moveForward()collectGem()moveForward()collectGem()go()moveForward..
Playgrounds '플레이그라운드' 14. .코드.let expert = Expert()expert.moveForward()expert.turnLockUp()expert.turnLeft()expert.turnRight()Expert 유형의 인스턴스를 초기화하고 turnLockUp() 메소드로 퍼즐을 풀어 보세요.for i in 1 ... 3 {expert.moveForward()}expert.turnLockUp()expert.turnLeft()expert.turnLeft()for i in 1 ... 3 {expert.moveForward()}expert.turnLeft()for i in 1 ... 3 {expert.moveForward()}expert.collectGem()expert.turnLeft()expert.turnLeft()for i i..
Playgrounds '플레이그라운드' 13. '코드' 각 포털의 상태를 변경하여 보석을 수집해 보세요.bluePortal.isActive = falsebluePortal.isActive = truepinkPortal.isActive = falsepinkPortal.isActive = truebluePortal.isActive = falsepinkPortal.isActive = falsefor i in 1 ...3 {moveForward()}collectGem()pinkPortal.isActive =trueturnRight()turnRight()moveForward()turnRight()turnRight()moveForward()collectGem()turnRight()turnRight()bluePortal.isActive = truefor i in..
Playgrounds '플레이그라운드' 12. '코드'포털을 비활성화하여 스위치에 도달해 보세요.greenPortal.isActive = truegreenPortal.isActive = falsegreenPortal.isActive = falsefor i in 1 ... 6 {moveForward()}toggleSwitch()turnRight()turnRight()for i in 1 ... 3 {moveForward()}toggleSwitch()turnRight()turnRight()for i in 1 ... 6 {moveForward()}toggleSwitch()