1 / 10

MetroUI package Metro; import java.util.Scanner ; public class MetroUI {

MetroUI package Metro; import java.util.Scanner ; public class MetroUI { MetroService service = new MetroService (); double MIN = 100; int NUM = 0; public void talk(){ service.info(); System. out.println (" 위도 경도 순으로 입력해주세요 ."); } public void process(){

Download Presentation

MetroUI package Metro; import java.util.Scanner ; public class MetroUI {

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MetroUI package Metro; import java.util.Scanner; public class MetroUI { MetroService service = new MetroService(); double MIN = 100; int NUM = 0; public void talk(){ service.info(); System.out.println("위도 경도 순으로 입력해주세요."); } public void process(){ Scanner scan = new Scanner(System.in); double wedo = scan.nextDouble(); double gydo = scan.nextDouble(); for(inti=0;i<=9;i++){ MetroVO info=service.information(i); double road = (info.wido-wedo)*(info.wido-wedo)+(info.Gydo-gydo)*(info.Gydo-gydo); if(road<MIN){ MIN=road; NUM=i; } } MetroVO info=service.information(NUM); System.out.println(info.name); } }

  2. MetroService package Metro; public class MetroService { MetroVO[] metroArr; public void info(){ metroArr = new MetroVO[10]; metroArr[0] = new MetroVO("이대역",37.5605,126.946823); metroArr[1] = new MetroVO("이태원역",37.534981,126.994719); metroArr[2] = new MetroVO("방화역",37.578052,126.812804); metroArr[3] = new MetroVO("고덕역",37.555431,126.1540881 ); metroArr[4] = new MetroVO("숭실대입구역",37.496789,126.953523); metroArr[5] = new MetroVO("어린이대공원역",37.555465,127.076111); metroArr[6] = new MetroVO("양평역",37.526065,126.886597); metroArr[7] = new MetroVO("청량리역",37.580229,127.047958); metroArr[8] = new MetroVO("미아역",37.626197,127.024956); metroArr[9] = new MetroVO("가좌역",37.568256,126.914749); } public MetroVO information(inti){ return metroArr[i]; } }

  3. MetroServiceTest package Metro; public class MetroServiceTest { public static void main(String[] args){ MetroUIui = new MetroUI(); ui.talk(); ui.process(); } }

  4. MetroVO package Metro; public class MetroVO { String name; double wido; double Gydo; public MetroVO(String name, double wido, double gydo) { super(); this.name = name; this.wido = wido; Gydo = gydo; } @Override public String toString() { return "MetroVO [name=" + name + ", wido=" + wido + ", Gydo=" + Gydo + "]"; } }

  5. LottoUI.java • import java.util.Scanner; • public class LottoUI { • LottoService service = new LottoService(); • public void talk(){ • service.stat(); • service.rand(); • System.out.println("숫자 6개를 입력해주세요."); • } • public void process(){ • int[] choose; • choose = new int[10]; • int check=0; • Scanner scan = new Scanner(System.in); • for(inti=0;i<6;i++){ • choose[i] = scan.nextInt(); • } • for(inti=0;i<6;i++){ • for(int j=1;j<=45;j++){ • LottoVO info=service.give(j); • if(info.check==true&&choose[i]==info.number) check++; • } • } • System.out.println(check); • } • }

  6. LottoVO.java • public class LottoVO { • int number; • boolean check; • public LottoVO(int number, boolean check) { • super(); • this.number = number; • this.check = check; • } • @Override • public String toString() { • return "LottoVO [number=" + number + ", check=" + check + "]"; • } • }

  7. LottoService.java • public class LottoService { • LottoVO[] LottoArr; • int count = 0; • public void stat(){ • LottoArr = new LottoVO[46]; • for(inti=1;i<=45;i++){ • LottoArr[i] = new LottoVO(i,false); • } • } • public void rand(){ • while(count<6){ • int result =1+(int)(Math.random()*45); • while(LottoArr[result].check){ • result%=45; • result++; • } • LottoArr[result].check=true; • count++; • } • } • public LottoVO give(inti){ • return LottoArr[i]; • } • }

  8. LottoServiceTest.java • public class LottoServiceTest { • public static void main(String[] args){ • LottoUI test = new LottoUI(); • test.talk(); • test.process(); • /*LottoUI test = new LottoUI(); • test.talk(); • test.process();*/ • } • }

More Related