본문 바로가기

IT82

Java (메소드 호출_Car) package p0528; class Car{ public int speed;//현재속도가 저장됨 public int getSpeed() { return speed;//현재속도를 반환 } public void keyTurnOn() { System.out.println("키를 돌립니다."); } public void run() { for(int i=10; i 2021. 5. 28.
Java (메소드 호출_주사위) 현재 클래스는 2개 public은 main이 있는 클래스에만 사용 가능 package p0528Dice; import java.util.Scanner; class Dice { int diceFace; //입력수 int RollDice; //랜덤수 public void startPlaying() { System.out.print("예상값을 입력하시오: "); Scanner scan = new Scanner(System.in); diceFace = scan.nextInt(); RollDice();//난수발생 메소드 } public void RollDice() { RollDice = (int) (Math.random() * 5) + 1; System.out.println(RollDice); compare();.. 2021. 5. 28.
C# (배열을 이용하여 일주일 날씨 통계 출력) using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace RoadBook.CsharpBasic.Chapter01.p0525 { class Ex002 { public void Run() { string[] weathers = new string[7]; weathers[0] = "suuny"; weathers[1] = "suuny"; weathers[2] = "rainy"; weathers[3] = "cloudy"; weathers[4] = "rainy"; weathers[5] = "snow"; weathers[6] = "suuny"; int.. 2021. 5. 25.
Java (this생성자_Phonebook) package phonebook01; public class Phonebook { /*필드*/ //이름 전화번호 주소 String name; int tel; String add; /*생성자*/ Phonebook(String name, int tel, String add){ this.name = name; this.tel = tel; this.add = add; } Phonebook(String name, int tel){ this(name, tel, null); } /*메소드*/ void print() { System.out.printf("name: %s\n", name); System.out.printf("phone: %d\n", tel); if(add!=null) { System.out.printf(.. 2021. 5. 24.