KangMoo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    ## 과제_1 : 은행 계좌 관리 시스템 목표 : OOP 특징을 활용하여 클래스를 설계한다. 요구사항 : 은행 계좌 관리 시스템을 구현하고자 한다. 계좌 종류는 두 가지로, `SavingsAccount`와 `CheckingAccount`가 있다. 두 계좌 모두 계좌 번호, 소유자 이름, 잔액, 계좌 상태를 가지고 있다. `SavingsAccount`는 이자율 필드를 추가로 가지고 있고, `CheckingAccount`는 최대 대출 가능 금액과 현재 대출한 금액 필드를 추가로 가지고 있다. `SavingsAccount`는 다음과 같이 설계한다 - `SavingsAccount`는 다음과 같은 필드를 가진다 - 계좌 번호(`accountNumber`) - 소유자 이름(`owner`) - 잔액(`balance`) - 계좌 상태(`status`) - 이자율(`interestRate`) - `SavingsAccount`는 다음과 같은 메서드를 가진다 - 계좌 번호, 소유자 이름, 잔액을 인자로 받아 초기화하는 생성자 - 입금 금액을 인자로 받아 잔액 필드에 더하는 `deposit()` 메서드 - 출금 금액을 인자로 받아 잔액 필드에서 빼는 `withdraw()` 메서드 - 잔액 필드를 반환하는 `getBalance()` 메서드 - 계좌 상태를 반환하는 `getStatus()` 메서드 - 계좌 상태를 변경하는 `setStatus()` 메서드 - 이자율 필드를 반환하는 `getInterestRate()` 메서드 - 이자율 필드를 변경하는 `setInterestRate()` 메서드 - 이자율과 잔액을 곱한 금액을 잔액에 더하는 `addInterest()` 메서드 - 계좌 정보를 출력하는 `printAccountInfo()` 메서드 `CheckingAccount`는 다음과 같이 설계한다 - `CheckingAccount`는 다음과 같은 필드를 가진다 - 계좌 번호(`accountNumber`) - 소유자 이름(`owner`) - 잔액(`balance`) - 계좌 상태(`status`) - 최대 대출 가능 금액(`creditLimit`) - 현재 대출한 금액(`loanBalance`) - `CheckingAccount`는 다음과 같은 메서드를 가진다 - 계좌 번호, 소유자 이름, 잔액을 인자로 받아 초기화하는 생성자 - 입금 금액을 인자로 받아 잔액 필드에 더하는 `deposit()` 메서드 - 출금 금액을 인자로 받아 잔액 필드에서 빼는 `withdraw()` 메서드 - 잔액 필드를 반환하는 `getBalance()` 메서드 - 계좌 상태를 반환하는 `getStatus()` 메서드 - 계좌 상태를 변경하는 `setStatus()` 메서드 - 최대 대출 가능 금액 필드를 반환하는 `getCreditLimit()` 메서드 - 최대 대출 가능 금액 필드를 변경하는 `setCreditLimit()` 메서드 - 현재 대출한 금액 필드를 반환하는 `getLoanBalance()` 메서드 - 대출 금액을 인자로 받아 현재 대출한 금액 필드에 더하는 `loan()` 메서드 - 대출 금액을 인자로 받아 현재 대출한 금액 필드에서 빼는 `repayLoan()` 메서드 - 계좌 정보를 출력하는 `printAccountInfo()` 메서드 위 두 클래스를 설계해본다. 이때, 다음과 같은 사항을 고려한다 1. Enum 활용 - 계좌 상태를 나타내는 Enum을 정의한다 (예: `ACTIVE`, `INACTIVE`, `SUSPENDED`) 2. 인터페이스 활용 - `Account` 인터페이스를 사용하여 공통적으로 사용되는 메서드는 이 인터페이스에 정의한다 3. 추상 클래스 활용 - `Account` 인터페이스를 구현하는 `AbstractAccount` 추상 클래스를 정의한다 - `AbstractAccount`는 공통적으로 사용되는 필드 및 메서드를 구현한다 4. 입력 유효성 검사 - 사용자 입력이 유효한지 검사하는 로직을 구현한다 (예: 음수 금액의 입금 또는 출금 방지) ## 과제_2 : 프로그래머스 문제 풀기 1. [겹치는 선분의 길이](https://school.programmers.co.kr/learn/courses/30/lessons/120876) --- ## 과제_1 : 은행 계좌 관리 시스템 모범답안 ```java public enum AccountStatus { ACTIVE, INACTIVE, SUSPENDED } public interface Account { void deposit(double amount); void withdraw(double amount); double getBalance(); AccountStatus getStatus(); void setStatus(AccountStatus status); void printAccountInfo(); } public abstract class AbstractAccount implements Account { private String accountNumber; private String owner; private double balance; private AccountStatus status; public AbstractAccount(String accountNumber, String owner, double balance) { this.accountNumber = accountNumber; this.owner = owner; this.balance = balance; this.status = AccountStatus.ACTIVE; } @Override public void deposit(double amount) { if (amount < 0) { System.out.println("입금 금액은 음수가 될 수 없습니다."); return; } balance += amount; } @Override public void withdraw(double amount) { if (amount < 0) { System.out.println("출금 금액은 음수가 될 수 없습니다."); return; } balance -= amount; } @Override public double getBalance() { return balance; } @Override public AccountStatus getStatus() { return status; } @Override public void setStatus(AccountStatus status) { this.status = status; } @Override public void printAccountInfo() { System.out.println("계좌 번호: " + accountNumber); System.out.println("소유자 이름: " + owner); System.out.println("잔액: " + balance); System.out.println("계좌 상태: " + status); } } public class SavingsAccount extends AbstractAccount { private double interestRate; public SavingsAccount(String accountNumber, String owner, double balance, double interestRate) { super(accountNumber, owner, balance); this.interestRate = interestRate; } public double getInterestRate() { return interestRate; } public void setInterestRate(double interestRate) { this.interestRate = interestRate; } public void addInterest() { deposit(getBalance() * interestRate); } } public class CheckingAccount extends AbstractAccount { private double creditLimit; private double loanBalance; public CheckingAccount(String accountNumber, String owner, double balance, double creditLimit) { super(accountNumber, owner, balance); this.creditLimit = creditLimit; this.loanBalance = 0; } public double getCreditLimit() { return creditLimit; } public void setCreditLimit(double creditLimit) { this.creditLimit = creditLimit; } public double getLoanBalance() { return loanBalance; } public void loan(double amount) { if (amount < 0) { System.out.println("대출 금액은 음수가 될 수 없습니다."); return; } if (amount > creditLimit) { System.out.println("대출 금액이 한도를 초과합니다."); return; } loanBalance += amount; deposit(amount); } public void repayLoan(double amount) { if (amount < 0) { System.out.println("상환 금액은 음수가 될 수 없습니다."); return; } if (amount > loanBalance) { System.out.println("상환 금액이 대출 잔액을 초과합니다."); return; } loanBalance -= amount; withdraw(amount); } } public class Main { public static void main(String[] args) { SavingsAccount sa = new SavingsAccount("123-45-67890", "홍길동", 100000, 0.05); sa.printAccountInfo(); sa.deposit(100000); sa.printAccountInfo(); sa.withdraw(50000); sa.printAccountInfo(); sa.addInterest(); sa.printAccountInfo(); CheckingAccount ca = new CheckingAccount("123-45-67890", "홍길동", 100000, 100000); ca.printAccountInfo(); ca.deposit(100000); ca.printAccountInfo(); ca.withdraw(50000); ca.printAccountInfo(); ca.loan(100000); ca.printAccountInfo(); ca.repayLoan(50000); ca.printAccountInfo(); } } ``` ## 과제_2 : 프로그래머스 문제 풀기 모범 답안 1. 겹치는 선분의 길이 ```java class Solution { public int solution(int[][] lines) { int[] points = new int[lines.length * 2]; for (int i = 0; i < lines.length; i++) { points[i * 2] = lines[i][0]; points[i * 2 + 1] = lines[i][1]; } bubbleSort(points); int overlap = 0; for (int i = 0; i < points.length - 1; i++) { int count = 0; for(int j = 0; j < lines.length; j++){ if(lines[j][0] <= points[i] && points[i + 1] <= lines[j][1]){ count++; } } if (count >= 2) { overlap += points[i + 1] - points[i]; } } return overlap; } public static void bubbleSort(int[] array) { int n = array.length; for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (array[j] > array[j + 1]) { int temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; } } } } } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully