20220217 º¹½À


< ÇÁ·Î±×·¥ ¸¸µå´Â ±âº» Æû >

·¹°í°ü¸®, ¿¹¾à½Ã½ºÅÛ°ü¸®, ¼ºÀû°ü¸® (java, jsp&servlet(web), db, spring, project) µî
--------------------------------------------
º¯¼ö price / total / cnt µî
ÇÔ¼ö print(¹è¿­À̸§) / year(¹è¿­À̸§, ¿¬µµ)

     static ¸®ÅÏÇü ÇÔ¼ö¸í(ÀÚ·áÇü ÀԷ°ª, )
     {
          ÇÔ¼ö ³»¿ë;
          return Ãâ·Â°ª;
     {

Á¦¾î¹®(Á¶°Ç¹®, ¹Ýº¹¹®)
¹è¿­
----------------------------
ÆÄÀÏ, DB
----------------------------
> Ŭ·¡½º

Tip !
Çâ»óµÈ for¹® Áß for(String[ ] lego : Lego) °®°í¿À´Â ¹è¿­¸í°ú ¸¸µå´Â ¹è¿­¸í ´ë¼Ò¹®ÀÚ ±¸ºÐ °¡´É
ÂüÁ¶º¯¼ö = ÁÖ¼Ò
p184 À妽º = ¹è¿­ÀÇ ¿ä¼Ò¸¶´Ù ºÙ¿©Áø ÀϷùøÈ£


< ·¹°í°ü¸® ½Ã½ºÅÛ (¸ñ·Ï, ÃÑ °¡°Ý, °Ë»ö) >

class LegoMVC//Model View Controller
{
     static void print(String[][] Lego)
     {
          for (String[] lego : Lego)
          {
               System.out.printf("[%s]",lego[0]);
               System.out.printf("[%s]",lego[1]);
               System.out.printf("[%s]",lego[2]);
               System.out.println();
          }
     }

     static int total(String[][] Lego)
     {
          int totalPrice=0;
          for (String[] lego : Lego)
          {
               totalPrice+=Integer.parseInt(lego[2]);
          }
          return totalPrice;
     }

     static boolean search(String[][] Lego, String key)
     {
          boolean answer=true;
          for (String[] lego : Lego)
          {
               if (lego[1].equals(key))
               {
                    answer=true;
                    break;
               }else{
                    answer=false;
               }
          }
          return answer;
     }

     public static void main(String[] args)
     {
          // µ¥ÀÌÅÍ°ü¸®(º¯¼ö > ¹è¿­ > ÆÄÀÏ > DB)
          // p184 À妽º = ¹è¿­ÀÇ ¿ä¼Ò¸¶´Ù ºÙ¿©Áø ÀϷùøÈ£ !
          String[][] Lego = new String[][]{
               {"1","·¹°í1","100"},
               {"2","·¹°í2","200"},
                {"3","·¹°í3","300"}
          };

          //init(); //°Ë»ö ½Ã°£ ´ÜÃàÀ» À§ÇØ Á¤·Ä !
          print(Lego);
          System.out.println("----------------------");
          System.out.println("ÇÕ°è: "+total(Lego));
          System.out.println("----------------------");
          if (search(Lego, "·¹°í3"))
          {
               System.out.println("·¹°í3Àº Á¸ÀçÇÑ´Ù.");
          }else{
               System.out.println("·¹°í3Àº Á¸ÀçÇÏÁö ¾Ê´Â´Ù.");
          }
     }
}