국비수업/CODE

code 실습 / 2️⃣1️⃣

밀김 2023. 3. 16. 16:25
728x90

 

 

 

 

 

 

 

 

 

 

 

✏️ Has A 상속이란? 설명해보기

필요한 부품(인자?)를 갖고와서 조립하는것 (컴포지션,어그리게이션)

 

✏️ Composition Has A 관계란? drawio 활용하여 그림을 그려보고 설명해보세요.

어떤것을 갖고 구성하고 있다. 일체형으로라고도 불리워지며,객체를 호출했을때 그 객체가 갖고 있는 클래스 객체도 자동 생성되는것

 

 

✏️Association Has a 관계란? drawio 활용하여 그림을 그려보고 설명해보세요.
분리형이라고도 하며 일체형과 다르게 객체 호출시 매번 필요한 부품,객체를 생성해줘야하며 setter를 이용해 인자를 받아서 사용한다. 다른 객체 안에 포함되어 있으면서도,분리되어 존재할수도 있다

 

 

 

 

⭐️ 다음 설계를 Java의 class를 이용하여 코드로 작성하세요. 메소드는 구현하는 것이 아닙니다!   

GameCanvas field에 Background 참조변수가 빠진거 같아요.

첫번째 칸: 클래스 이름 두번째 칸: 필드(변수이름,값형태) 세번째 칸:메소드

 

- 화살표방향을 작살이라고 생각. 가져와야 되니까 꽂고 끌고오는것! 

- 원하는 속성을 사용하면서 자기껄 추가하는거 > 프레임워크

 

 

public class GameCanvers {
	private Item[] items;
	private int width;
	private int height;
	private Background background;
	
	public GameCanvers() {
		items = new Item[10]; //어그리게이션
		Background background = new Background();//컴포지션 되면서
	}
	
	public boolean run() {
		return true;
	}
	
	public boolean pause() {
		return false;
	}
	
}

<GameCanvas>
- : private
+ : public

run() : boolean / 반환타입이 boolean형식이고 매개인자는 없다

하얀 마름모 : 어그리게이션(어그리게이션은 분리,일체 아무것도 아님. 컴포지션 )

0.10은 배열의 길이를 의미.Items[10] 

 

 

 

public class Item {
	private int x;
	private int y;
	private String img;
	
	public void moveTo (int x,int y) {
	 //void라서 이렇게만 만들어줘도 된다
	}
	
	public void move (int direction) {
		return ;
	}
	
	public void bomb() {
		
	}
}

<Item>
moveTo(x:int,y:int) / 반환타입은 없고, 매개인자는 int x,int y다

 

 

 

public class Missile extends Item {
	private int weight;
}

<Missile>
쏘는 화살표는 extends를 의미하고 화살표(extends)는 Item의 속성을 갖고 와서 Missile에서 쓴다는 의미
추가로, Missile 자체에서 더 속성을 추가하고싶으면 해도 된다 

 

 

 

 

public class Fighter extends Item {
	private int angle;
	private Missile[] missiles;
	
	public Fighter() {
		missiles = new Missile[20];
	}
	public Missile fire() {
		return missiles[0];
	}
}

<Fighter>
0.20 : Missile을 끌고 와서 20칸짜리 배열을 만든다 

하얀 마름모: 어그리게이션 

 

 

 

 

public class Background {
	private int y;
	private int speed;
	
	public void rollup() {
		
	}
}

<Background>
- rollup() : 반환타입과 매개인자가 없다 

 

 

- 마름모 위치: 메인이 되는 객체??쪽에 마름모 대가리가 가게끔 

 

- 생성자에서 객체 생성시 일체형이다

 

- 컴포지션 방식으로 헤즈어 했다 > A라는 객체가 만들어질때 B라는 객체도 같이 만들어진다

 

 

 


 

✏️ 17:30 ~ HTML CSS 간단한 네비게이션 실습.

  • 웹 접근성에 맞는 시맨틱 태그를 사용하기
  • 마우스 hover -> 배경을 #3B82C3로

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="../HomeWork/index.css" type="text/css">
<body>
    
    <section>
        <div class="home">Home</div>
        <div class="notice">Notice</div>
        <div class="about">About us</div>
        <div class="sign">Sign in</div>
    </section>

</body>
</html>

 

*{
    margin: 0 auto;
    padding: 0 auto;
}

section{
    text-align: center;
    font-size: 0px;
    letter-spacing: 0;
    word-spacing: 0;
}

div{
    display: inline-block;
    margin: 0;
    font-size: 30px;
    font-weight: bold;
    height: 24vh;
    width: 40vh;
    text-align: center;
    line-height: 5em;
    background-color:#BEC3C8;
}

div:hover{
    background-color: #3B82C3;
    transition-duration: 1s;
    color: white;
}

 

 

 

728x90