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 New
    • 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 Note Insights Versions and GitHub Sync 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ## 과제_1 : 제네릭 리스트 구현 목표 : 제네릭을 사용하여 다양한 데이터 타입을 저장할 수 있는 배열 리스트와 연결 리스트를 구현한다. 요구사항 : 다음 코드를 참고하여, 제네릭을 사용하여 다양한 데이터 타입을 저장할 수 있는 배열 리스트와 연결 리스트를 구현한다. ```java public class MyArrayList { private int[] array; private int size; public MyArrayList() { array = new int[10]; size = 0; } public void add(int value) { if (size >= array.length) { int[] newArray = new int[array.length * 2]; System.arraycopy(array, 0, newArray, 0, array.length); array = newArray; } array[size++] = value; } public int get(int index) { return array[index]; } public int size() { return size; } public void remove(int index) { System.arraycopy(array, index + 1, array, index, size - index - 1); size--; } } ``` ```java public class MyLinkedList { public class Node { int data; Node next; public Node(int data) { this.data = data; } } private Node head; private int size; public void add(int value) { Node newNode = new Node(value); if (head == null) { head = newNode; } else { Node last = head; while (last.next != null) { last = last.next; } last.next = newNode; } size++; } public int get(int index) { Node node = head; for (int i = 0; i < index; i++) { node = node.next; } return node.data; } public int size() { return size; } public void remove(int index) { if (index == 0) { head = head.next; } else { Node node = head; for (int i = 0; i < index - 1; i++) { node = node.next; } node.next = node.next.next; } size--; } } ``` ## 과제_2 : WORDLE 게임 구현 목표 : 단어 맞추기 게임을 구현해본다. 요구사항 : 다음 조건을 만족하는 단어 맞추기 게임을 구현한다. 1. 프로그램은 5자리 단어 목록에서 무작위로 단어 하나를 선택해야 한다. - 단어 목록은 원하는 대로 설정한다. - ex) `SHAKE`, `SHARE`, `PANIC`, `AMUSE`, `SHADE`, ... 2. 사용자는 총 6번의 기회로 단어를 추측할 수 있다. 3. 각 추측 후, 프로그램은 다음과 같이 피드백을 제공해야 한다: - 정확한 위치에 있는 글자는 녹색 배경으로 표시한다. - 단어에 포함되나 위치가 틀린 글자는 노란색 배경으로 표시한다. - 단어에 포함되지 않은 글자는 아무런 색상 변화 없이 표시한다. - 색상 표현 방법은 ANSI 색상 코드를 사용한다. 4. 사용자가 정답을 맞히면, `Correct! You win!`을 출력하고 게임을 종료한다. 5. 6번의 시도 후에도 정답을 맞히지 못하면, `Wrong! The correct word is [정답].`을 출력하고 게임을 종료한다. 6. 입력받은 추측 단어는 대문자로 변환되어 처리해야 한다. ### ANSI 색상 코드 사용법 ANSI 색상 코드 : 터미널이나 콘솔에서 문자의 색상과 스타일을 제어하는 데 사용되는 특별한 코드 이 코드는 ANSI(Escape Sequence) 이스케이프 시퀀스라는 표준에 기반하여, 텍스트의 색상, 밝기, 스타일 등을 변경할 수 있다. ANSI 색상 코드란 텍스트 색상을 변경하기 위한 특수한 문자열이다. ANSI 색상 코드를 사용하여 Java 콘솔 응용 프로그램에서 텍스트 색상을 변경할 수 있다. | 색상 | 코드 | | --- | --- | | 녹색 | `\u001b[42m` | | 노란색 | `\u001b[43m` | | 리셋 | `\u001b[0m` | 배경을 `녹색` -> `노란색` -> `리셋`하는 예시 코드 ```java System.out.print("\u001b[42m" + "이 텍스트는 녹색 배경을 가지고 있다." + "\u001b[43m" + "이 텍스트는 노란색 배경을 가지고 있다." + "\u001b[0m" + "이 텍스트는 기본색상이다."); ``` > ANSI는 위의 내용보다 훨씬 더 많은 기능을 제공하므로, 더 많은 정보를 원한다면 구글링을 통해 찾아보자. --- ## 과제_1 : 제네릭 리스트 구현 모범답안 ```java public class MyArrayList<T> { private T[] array; private int size; public MyArrayList() { array = (T[]) new Object[10]; size = 0; } public void add(T value) { if (size >= array.length) { T[] newArray = (T[]) new Object[array.length * 2]; System.arraycopy(array, 0, newArray, 0, array.length); array = newArray; } array[size++] = value; } public T get(int index) { return array[index]; } public int size() { return size; } public void remove(int index) { System.arraycopy(array, index + 1, array, index, size - index - 1); size--; } } ``` ```java public class MyLinkedList<T> { public class Node { T data; Node next; public Node(T data) { this.data = data; } } private Node head; private int size; public void add(T value) { Node newNode = new Node(value); if (head == null) { head = newNode; } else { Node last = head; while (last.next != null) { last = last.next; } last.next = newNode; } size++; } public T get(int index) { Node node = head; for (int i = 0; i < index; i++) { node = node.next; } return node.data; } public int size() { return size; } public void remove(int index) { if (index == 0) { head = head.next; } else { Node node = head; for (int i = 0; i < index - 1; i++) { node = node.next; } node.next = node.next.next; } size--; } } ``` --- ## 과제_2 : WORDLE 게임 구현 모범 답안 ```java import java.util.Scanner; class Wordle { public static void main(String[] args) { final String BG_GREEN = "\u001b[42m"; final String BG_YELLOW = "\u001b[43m"; final String RESET = "\u001b[0m"; System.out.println("WORDLE!"); String[] words = {"SHAKE", "SHARE", "PANIC", "AMUSE", "SHADE"}; int wIndex = (int)(Math.random() * words.length); String correct = words[wIndex]; Scanner sc = new Scanner(System.in); String guess = ""; // Loop for six guesses for(int round=0;round<6;round++) { System.out.print("Please guess. > "); guess = sc.nextLine().toUpperCase(); // Create a loop to iterate through each letter for(int i=0;i<5;i++) { if(guess.substring(i, i+1).equals(correct.substring(i, i+1))) { // Letter matches System.out.print(BG_GREEN + guess.substring(i, i+1) + RESET); } else if(correct.indexOf(guess.substring(i, i+1)) > -1) { // Letter is in word, but different location System.out.print(BG_YELLOW + guess.substring(i, i+1) + RESET); } else { // Letter not in word System.out.print(guess.substring(i, i+1)); } } System.out.println(""); // If the guess is correct if(guess.equals(correct)) { System.out.println("Correct! You win!"); break; } } // Print correct answer if player loses if(!guess.equals(correct)) { System.out.println("Wrong! The correct word is " + correct + "."); } } } ```

    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