<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>Java by 김준형</title>
      <link>https://padlet.com/baba0206_/J_java</link>
      <description>방학특강</description>
      <language>en-us</language>
      <pubDate>2025-01-06 03:29:31 UTC</pubDate>
      <lastBuildDate>2025-01-09 02:34:46 UTC</lastBuildDate>
      <webMaster>hello@padlet.com</webMaster>
      <image>
         <url>https://padlet.net/icons/png/1f4da.png</url>
      </image>
      <item>
         <title>끝말잇기 게임</title>
         <author>baba0206_</author>
         <link>https://padlet.com/baba0206_/J_java/wish/3280506859</link>
         <description><![CDATA[<pre><code>import java.util.Scanner;

class Player {
    private String name;
    Scanner scanner;
    private String word;

    public Player() {
        scanner = new Scanner(System.in);
        System.out.print("참가자의 이름을 입력하세요: ");
        this.name = scanner.nextLine();
    }

    String getName() {
        return name;
    }

    String getWordForUser() {
        System.out.print(name + "&gt;&gt; ");
        word = scanner.nextLine();
        return word;
    }

    public boolean checkSuccess(String lastWord) {
        int lastIndex = lastWord.length() - 1;
        return lastWord.charAt(lastIndex) == word.charAt(0);
    }
}

class WordGame {
    Player[] players;
    Scanner scanner = new Scanner(System.in);
    int number;

    void run() {
        System.out.println("끝말잇기 게임을 시작합니다....");
        System.out.print("게임에 참가하는 인원은 몇 명 입니까? ");
        number = scanner.nextInt();
        scanner.nextLine(); // Consume the newline character

        players = new Player[number];
        for (int i = 0; i &lt; number; i++) {
            players[i] = new Player();
        }

        String word = "아버지";
        System.out.println("시작하는 단어는 " + word + "입니다.");

        int currentPlayerIndex = 0;
        while (true) {
            Player currentPlayer = players[currentPlayerIndex];
            String inputWord = currentPlayer.getWordForUser();

            if (!currentPlayer.checkSuccess(word)) {
                System.out.println(currentPlayer.getName() + "이(가) 졌습니다!");
                break;
            }

            word = inputWord;
            currentPlayerIndex = (currentPlayerIndex + 1) % number;
        }

        System.out.println("게임이 종료되었습니다.");
    }
}

public class WordGameApp {
    public static void main(String[] args) {
        WordGame game = new WordGame();
        game.run();
    }
}</code></pre>]]></description>
         <enclosure url="" />
         <pubDate>2025-01-06 03:29:55 UTC</pubDate>
         <guid>https://padlet.com/baba0206_/J_java/wish/3280506859</guid>
      </item>
      <item>
         <title>HashMap</title>
         <author>baba0206_</author>
         <link>https://padlet.com/baba0206_/J_java/wish/3283232642</link>
         <description><![CDATA[<pre><code>import java.util.*;

public class StockEx {
    public static void main(String[] args) {
        HashMap&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;();
        Scanner scanner = new Scanner(System.in);

        System.out.println("주식 종목과 주가를 입력하세요(예:삼송전자 75000)");
        while (true) {
            System.out.print("종목, 주가&gt;&gt;");
            String line = scanner.nextLine();

            if(line.equals("그만"))
                break;

            String[] arr = line.split(" ");
            String company = arr[0];
            int quantity = Integer.parseInt(arr[1]);

            map.put(company, quantity);
        }

        System.out.println("주가를 검색합니다.");
        while(true) {
            System.out.print("종목&gt;&gt;");
            String commpany = scanner.nextLine();

            if(commpany.equals("그만"))
                break;

            Integer quantity = map.get(commpany);

            if (quantity == null) {
                System.out.println(commpany + "는(은) 없는 종목입니다.");
            } else {
                System.out.println(commpany + " 의 주가는 " + quantity + "원");
            }
        }
        scanner.close();
    }
}</code></pre>]]></description>
         <enclosure url="" />
         <pubDate>2025-01-08 02:27:14 UTC</pubDate>
         <guid>https://padlet.com/baba0206_/J_java/wish/3283232642</guid>
      </item>
      <item>
         <title>ArrayList사용</title>
         <author>baba0206_</author>
         <link>https://padlet.com/baba0206_/J_java/wish/3284563272</link>
         <description><![CDATA[<pre><code>import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;

class Stock {
    ArrayList&lt;String&gt; productsList = new ArrayList&lt;String&gt;();
    ArrayList&lt;Integer&gt; priceList = new ArrayList&lt;Integer&gt;();

    private void storeStock(){
        productsList.add("고추장");
        priceList.add(3000);
        productsList.add("만두");
        priceList.add(500);
        productsList.add("새우깡");
        priceList.add(1500);
        productsList.add("콜라");
        priceList.add(600);
        productsList.add("참치캔");
        priceList.add(2000);
        productsList.add("치약");
        priceList.add(1000);
        productsList.add("연어");
        priceList.add(2500);
        productsList.add("삼겹살");
        priceList.add(2500);
    }

    private void displayStock(){
        for(int i = 0; i&lt; productsList.size(); i++){
            String product = productsList.get(i);
            int price = priceList.get(i);
            System.out.print("[" + product + ", " + price+ "] ");
        }
        System.out.println();
    }

    private int getProductCost(String product, int price) {
        for(int i = 0; i&lt; productsList.size(); i++){
            String p = productsList.get(i);
            if (product.equals(p)) {
                int cost = priceList.get(i);
                return cost * price;
            }
        }
        return 0;
    }

    private void calculatePrice(StringTokenizer st){
        int cost = 0;
        while(st.hasMoreTokens()){
            String product = st.nextToken();
            int count = Integer.parseInt(st.nextToken());
            int price = getProductCost(product, count);

            if(price == 0){
                System.out.println(product + "은 없는 상품입니다!");
                return;
            } else {
                cost += price;
            }
            System.out.println("전체 비용은" + cost + "원 입니다.");
        }
    }

    public void run() {
        storeStock();
        System.out.println("쇼핑 비용을 계산해 드립니다. 구입 가능 물건과 가격은 다음과 같습니다.");
        displayStock();

        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.print("물건과 개수를 입력하세요&gt;&gt;");
            String line = scanner.nextLine();

            if(line.equals("그만")){
                break;
            }

            StringTokenizer st = new StringTokenizer(line);
            if(st.countTokens() % 2 != 0) {
                System.out.println("입력에 문제가 있습니다.");
                continue;
            }
            calculatePrice(st);
        }
        scanner.close();
    }
}

public class StockEx {
    public static void main(String[] args) {
        Stock stock = new Stock();
        stock.run();
    }
}</code></pre>]]></description>
         <enclosure url="" />
         <pubDate>2025-01-09 00:52:54 UTC</pubDate>
         <guid>https://padlet.com/baba0206_/J_java/wish/3284563272</guid>
      </item>
      <item>
         <title>마일리지 관리 프로그램</title>
         <author>baba0206_</author>
         <link>https://padlet.com/baba0206_/J_java/wish/3284667828</link>
         <description><![CDATA[<pre><code>import java.util.*;

class MileageManage{
    HashMap&lt;String, Integer&gt; map = new HashMap&lt;String, Integer&gt;();
    Scanner scanner = new Scanner(System.in);

    private void inputMileage(){
        while(true){
            System.out.print("이름과 마일리지&gt;&gt;");

            String name = scanner.next();
            if(name.equals("그만")){
                break;
            }
            int mileage = scanner.nextInt();

            Integer value = map.get(name);//마일리지 가져오기
            if(value == null){
                map.put(name, mileage);
            } else { //고객이 있는 경우 기존 마일리지에 새로운 마일리지를 누적
                mileage += value;
                map.put(name, mileage);
            }
        }
    }
    private void printMileage(){
        Set&lt;String&gt; set = map.keySet();
        Iterator&lt;String&gt; iterator = set.iterator();
        String vipUser = ""; //마일리지가 가장 높은 사람 출력
        int bestMileage = 0;//최고의 마일리지 점수

        while(iterator.hasNext()){
            String name = iterator.next();
            int mileage = map.get(name);
            System.out.print("(" + name + ":" + mileage + ") ");

            if(mileage &gt; bestMileage){
                bestMileage = mileage;
                vipUser = name;
            }
        }
        System.out.println("\n가장 마일리지가 높은 고객은 " + vipUser + "입니다.");
    }

    public void run(){
        System.out.println("***마일리지 관리 프로그램 입니다.***");
        inputMileage();
        printMileage();
        System.out.println("프로그램을 종료합니다.");
    }
}

public class MileageManageEx {
    public static void main(String[] args) {
        MileageManage mileageManage = new MileageManage();
        mileageManage.run();
    }
}</code></pre>]]></description>
         <enclosure url="" />
         <pubDate>2025-01-09 02:34:45 UTC</pubDate>
         <guid>https://padlet.com/baba0206_/J_java/wish/3284667828</guid>
      </item>
   </channel>
</rss>
