[TIL] 220529

HJ Kim·2022년 5월 29일
0

TIL

목록 보기
2/27

- 자바의 정석 (도서)

Chapter 2 : 변수 (Variable)

1. 변수와 상수

변수 (Variable) : 값을 저장할 수 있는 메모리상의 공간
하나의 변수에 단 하나의 값만 저장 할 수 있으므로 새로운 값을 저장하면 기존의 값은 사라진다.

(1) 변수 선언

  • 변수의 선언 방법은 아래와 같음

변수타입 변수이름
(변수타입 : 정수형, 실수형, 문자형 등 다양한 타입 제공)
(변수이름 : 변수에 붙인 이름. 메모리 공간의 이름)
(ex. int age -> int가 변수타입 (정수를 나타내는 integer에서의 int), age가 변수이름)

(2) 변수 초기화

  • 변수 초기화는 아래와 같음
    -> 변수타입 변수이름 = 값;
    (ex. int age = 25;)
  • 전에 다른 프로그램에 의해 저장된 알 수없는 값, 즉 쓰레기값이 남아있을 수 있기 때문에 변수 초기화를 해야한다.

(3) 두 변수의 값 교환

int x = 10;
int y = 20;
의 경우 변수 x에 있는 값인 10을 y에, 변수 y에 있는 값인 20을 x에 넣는 방법

  • temp 변수 사용
    -> int tmp; (변수 x의 값인 10을 임시로 저장할 변수 선언)
    (1) 변수 x에 저장된 값을 변수 tmp에 저장
    tmp = x;
    (2) 변수 y에 저장된 값을 변수 x에 저장
    x = y;
    (3) 변수 tmp에 저장된 값을 변수 y에 저장
    y = tmp;

2. 변수의 타입

값의 종류에 따라 '문자와 숫자'로 나뉠 수 있으며 숫자는 크게 정수 및 실수로 나뉨.

이렇게 값의 종류에 따라 값이 저장되는 공간의 크기와 저장형식을 정의한 것이 자료형 (Data Type)이다.

자료형은 크게 2가지, '기본형'과 '참조형' 으로 나뉜다.

기본형 (Primitive Type) : 계산을 위해 실제 값(data)를 저장
(ex. 총 8개 - 논리형(boolean), 문자형(char), 정수형(byte, short, int, long) 실수형 (float, double))

참조형 (Referenca type) : 객체의 주소를 저장. 8개의 기본형을 제외한 나머지 타입.

- 항해 99 웹개발 종합반 강의 수강 (1주차)

(1) 필수 S/W 설치

  • Pycharm 설치 완료
  • AWS 계정 생성 완료

(2) HTML/CSS 기본 내용

  • HTML : head/body로 구성
    -> body : 기본 웹 페이지 내용 구성
    -> head : body에 들어가지 않는 내용들 (title, pavicon 등)
    -> 여러 tag들은 외우는 경우도 있지만 대부분 검색해서..

(3) CSS 기초

  • HTML이 뼈대라면 CSS는 꾸미기
  • 꾸민다는건 무언가를 가리킬 수 있어야 함
    -> 부를 수 있는 이름표를 만들고 그 이름표를 꾸며주면됨
  • body에서 구분자 (ex. class, id 등)을 넣어주고 head에서 style 을 넣어준다
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>로그인 페이지</title>
    <style> //이렇게 넣어준다
        .mytitle {
            color: red;
        }
    </style>
</head>
<body>
    <h1 class = "mytitle">로그인 페이지</h1> //class 지정
    <p>ID: <input type="text" /></p>
    <p>PW: <input type="text" /></p>
    <p><button> 로그인하기</button></p>
</body>
</html>

(4) 자주 쓰이는 CSS 연습하기

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>로그인 페이지</title>
    <style>
        .mytitle {
            width : 300px;
            height : 200px;
            color : white;
            text-align: center;

            background-image: url("https://www.ancient-origins.net/sites/default/files/field/image/Agesilaus-II-cover.jpg");
            background-size: cover;
            background-position: center;
			//위 3개는 거의 기본으로 쓰인다고 보면 됨
            
            border-radius: 10px;
            padding-top : 40px;
        }
        .wrap {
            width : 300px;
            margin : auto;
			// 가로길이를 주고 나서 margin을 주는
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div class="mytitle">
            <h1>로그인 페이지</h1>
            <h5>아이디, 비밀번호를 입력해 주세요</h5>
        </div>
        <p>ID: <input type="text" /></p>
        <p>PW: <input type="text" /></p>
        <p><button> 로그인하기</button></p>
    </div>
</body>
</html>

(5) 폰트, 주석, 파일분리

  1. 폰트
  • 원하는 폰트가 있으면 (ex 한글) https://fonts.google.com/?subset=korean 여기에서 원하는 글씨체 선택
  • 선택 후 link href 부분 및 font-family 부분 복사해서 붙여넣기 하면 됨
  1. 주석
  • 주석 달고 싶은 코드 부분을 전체선택
  • ctrl + /
  1. 파일분리
  • style 에 적은 내용이 길어지는 경우엔 해당 내용을 갖고 있는 style.css 파일로 따로 저장
<link rel="stylesheet" type="text/css" href = "(css파일이름).css">

(6) 부트스트랩, CSS 모음집

부트스트랩 (Bootstrap)이란 : 예쁜 CSS를 미리 모아둔 것. 시작 템플릿 이라 생각하면 될듯 (참조 사이트)

(7) CSS 한 번 더

<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>

<title>스파르타코딩클럽 | 부트스트랩 연습하기</title>
    <link href="https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap" rel="stylesheet">
    <style>
          * {
              font-family: 'Gowun Dodum', sans-serif;
            }
        .mytitle {
            background-color: green;
            width : 100%;
            height : 250px;

            background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url("https://movie-phinf.pstatic.net/20210715_95/1626338192428gTnJl_JPEG/movie_image.jpg");
            background-size: cover;
            background-position: center;

            color : white;

            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
			//위 4개는 가운데로 text 정렬할 때 쓰이는 set
        }
        .mytitle > button{
            width : 200px;
            height : 50px;

            background-color: transparent;
            color : white;
            border-radius: 50px;
            border : 1px solid white;
            margin-top : 10px;

        }
        //mytitle class 아래에 있는 button 지칭
        .mytitle > button:hover{
            border : 2px solid white;
        }
        //mytitle class 아래에 있는 button에 마우스 올라갈 때
    </style>
</head>

<body>
    <div class = "mytitle">
        <h1>내 생에 최고의 영화들</h1>
        <button>영화 기록하기</button>
    </div>

</body>

</html>

(8) 부트스트랩 써보기

(아까 (6) 에서 확인한 부트스트랩 사이트 에서 card 가져온 것.
똑같은 카드 4개니까 하나만 보면 된다)

        <div class="row row-cols-1 row-cols-md-4 g-4">
          <div class="col">
            <div class="card">
              <img src="https://movie-phinf.pstatic.net/20210728_221/1627440327667GyoYj_JPEG/movie_image.jpg" class="card-img-top" alt="...">
              <div class="card-body">
                <h5 class="card-title">여기에 제목이 들어갑니다.</h5>
                <p class="card-text">여기에 내용이 들어가지요.</p>
                  <p>⭐⭐⭐</p>
                  <p class="mycomment">여기에 코멘트가 들어갑니다.</p>
              </div>
            </div>
          </div>
profile
티끌모아 태산을 아는 사람

0개의 댓글