파란 블로그의 라삐 님께서 정리하신 Eclipse단축키 입니다.
원본 주소 : http://blog.paran.com/rabbii/14608118
 
Kind Category Name (Command) Key Sequence When Remark
Function
Key
File Rename F2 In Windows  
Edit Show Tooltip Description F2 Editing in Structured Text Editors  
Navigate Open Declaration F3 In Windows
Navigate Open Type Hierarchy F4 In Windows  
File Refresh F5 In Windows  
Run/Debug Debug Last Launched F11 In Windows  
Window Activate Editor F12 In Windows Editor창으로

←↓→
Arrow
Text Editing Scroll Line Down Ctrl+Down Editing Text  
Text Editing Scroll Line Up Ctrl+Up Editing Text  
Navigate Go to Previous Member Ctrl+Shift+Up Editing Java Source  
Navigate Go to Next Member Ctrl+Shift+Down Editing Java Source  
Navigate Backward History Alt+Left In Windows History
Navigate Forward History Alt+Right In Windows
Text Editing Move Lines Up Alt+Up Editing Text  
Text Editing Move Lines Down Alt+Down Editing Text  
Edit Select Previous Element Alt+Shift+Left Editing in Structured Text Editors Select…
Edit Select Next Element Alt+Shift+Right Editing in Structured Text Editors
Edit Select Enclosing Element Alt+Shift+Up Editing in Structured Text Editors
Edit Restore Last Selection Alt+Shift+Down Editing in Structured Text Editors
File
Control
File New Ctrl+N In Windows  
File New menu Alt+Shift+N In Windows  
File Close Ctrl+F4 In Windows  
File Close All Ctrl+Shift+F4 In Windows  
File Save Ctrl+S In Windows  
File Save All Ctrl+Shift+S In Windows  
File Print Ctrl+P In Windows  
File Properties Alt+Enter In Windows  
Goto
&
Move
Navigate Go to Line Ctrl+L Editing Text  
Navigate Go to Matching Bracket Ctrl+Shift+P Editing Java Source  
Navigate (Go to) Last Edit Location Ctrl+Q In Windows  
Navigate Previous Ctrl+, In Windows ★오류부분
   바로가기
Navigate Next Ctrl+. In Windows
Edit Find Next Ctrl+K Editing Text  
Edit Find Previous Ctrl+Shift+K Editing Text  
Eclipse Window Maximize Active View or Editor Ctrl+M In Windows 화면크게보 기
Window Next Editor Ctrl+F6 In Windows  
Window Previous Editor Ctrl+Shift+F6 In Windows  
Window Quick Switch Editor Ctrl+E In Windows  
Window Show Key Assist Ctrl+Shift+L In Dialogs and Windows ★키모음보 기
Comment Source Toggle Comment Ctrl+/, Ctrl+7, Ctrl+Shift+C Editing Java Source 한줄주석
Edit Add Block Comment Ctrl+Shift+/ Editing in Structured Text Editors 선택영역주 석
Edit Remove Block Comment Ctrl+Shift+\ Editing in Structured Text Editors  
Source Add Javadoc Comment Alt+Shift+J In Windows 주석자동추가
Java
Editor
Source Organize Imports Ctrl+Shift+O In Windows import 자동
Source Add Import Ctrl+Shift+M Editing Java Source import 커서
Source Indent Line Ctrl+I Editing Java Source  
Text Editing Open Structure Ctrl+F3 TapestryEditorScope  
Navigate Quick Outline Ctrl+O Editing Java Source  
Navigate Quick Hierarchy Ctrl+T Editing Java Source  
Edit Quick Fix Ctrl+1 Editing in Structured Text Editors ★빠른오류 수정
Eclipse
Editor
Navigate Open Resource Ctrl+Shift+R In Windows
Edit Find and Replace Ctrl+F In Windows  
Search Open Search Dialog Ctrl+H In Windows 자바찾기
Search References in Workspace Ctrl+Shift+G In Windows
Edit Content Assist Ctrl+Space In Dialogs and Windows
Edit Format Document Ctrl+Shift+F Editing in Structured Text Editors ★형식맞추 기
Text Editing To Lower Case Ctrl+Shift+Y Editing Text ★대소문자변경
Text Editing To Upper Case Ctrl+Shift+X Editing Text
Etc Edit Run Query command Ctrl+F9 Editing HQL  
Editor
Common
Key
Edit Select All Ctrl+A In Dialogs and Windows  
Edit Copy Ctrl+C, Ctrl+Insert In Dialogs and Windows  
Edit Cut Ctrl+X, Shift+Delete In Dialogs and Windows  
Edit Paste Ctrl+V, Shift+Insert In Dialogs and Windows  
Edit Redo Ctrl+Y In Windows  
Edit Undo Ctrl+Z In Windows  
Edit Delete Delete In Windows  
Text Editing Line End End Editing Text  
Text Editing Line Start Home Editing Text  
Text Editing Text Start Ctrl+Home Editing Text  
Text Editing Text End Ctrl+End Editing Text  


'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편,,,ㅠㅠ  (2) 2009.04.23
JAVA숙제,,,  (1) 2009.04.09
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25

그냥 이걸로 때울께요,,
더이상 자바는 저도 아는게 없고,,,
하지만 질문을하시면 언제든지 답변은 해드릴테니,,,
보시고 모르겠는부분은
nateon : dcmichael@nate.com
msn : dcmichael@live.co.kr
로 물어보시거나 여기에 덧글(덧글은 회원가입이 필요 없어요)로 남겨주시면 
12시간 이내로 답변 해드릴테니,,,
언제나 질문은 환영이예요,,!!

'대학생활 > JAVA' 카테고리의 다른 글

Eclipse 단축키  (0) 2010.03.21
JAVA숙제,,,  (1) 2009.04.09
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
JAVA숙제,,, 대학생활/JAVA 2009. 4. 9. 17:36

요즘 정신없이 사느라 티스토리도 못들어 오네요,,,ㄷㄷ
일단 이번숙제는

1. Write a unit conversion program that asks users to identify the unit from which they want to convert and the unit to which they want to convert. Available units should be mm, cm, m, ft, and in. Define two objects of a class UnitConverter that convert between meters and a given unit.
Convert from:
in
Convert to:
mm
Value:
10
10 in = 254 mm
Use the following class as your main class:
import java.util.Scanner;

/**
   This class converts between two units.
*/
public class ConversionCalculator
{
   public static void main(String[] args)
   {
      Scanner in = new Scanner(System.in);

      System.out.println("Convert from:");
      String fromUnit = in.nextLine();

      System.out.println("Convert to:");
      String toUnit = in.nextLine();

      UnitConverter from = new UnitConverter(fromUnit);
      UnitConverter to = new UnitConverter(toUnit);

      System.out.println("Value:") ;
      double val = in.nextDouble();

      double meters = from.toMeters(val);
      double converted = to.fromMeters(meters);

      System.out.println(val+ " "+ fromUnit+ " = "+ converted
            + " "+ toUnit);
   }
}


이거입니다.
mm, cm, m, ft, in중 2개를 선택받아 서로 단위를 변환하는 계산기 문제인데요,,
UnitConverter 란 클래스를 만들어서
생성자에서는 처음 들어간 string을 갖고 처음의 단위를 계산하고, toMeter라는 함수를 이용해서 공통단위인 Meter로 고침니다. 그다음 그Meter단위 숫자를 받아서 다시 원하는 단위로 고치는,,,


순서는 이렇습니다.

1. 먼저 2개의 단위를 입력받습니다.
2.  이것을 각각 from, to라는 UnitConverter클래스에 생성자의 인자로 주어 from, to의 단위를 정합니다.
3. 그다음 from을 meter로 바꾸는 함수를 이용해 meter값을 임시변수에 넣습니다.
4. meter단위인 임시변수를 to 에 집어넣어 to 단위로 바꿈니다.
5. 이것을 출력합니다.,,,

말은 쉽지만, 이걸 하려면 if노가다나 단위변환상수를 정해놔야겠군요,,,

'대학생활 > JAVA' 카테고리의 다른 글

Eclipse 단축키  (0) 2010.03.21
내맘대로 강좌 JAVA편,,,ㅠㅠ  (2) 2009.04.23
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
너무 늦었지만, 공지합니다.
이번 숙제는 두개의 수를 입력받을수 있고
합, 차, 곱, 평균, 차이의 절대값, 둘중 큰수, 둘중 작은수
들을 출력할수 있는 클래스 Pair을 설계하는것 이 첫번째 숙제고요,

두번째는 DataSet 라는 클래스를 설계해서 값을 입력받고, 입력받은값중
제일 큰 수와 제일 작은수를 출력하는 클래스를 설계하랍니다.

우선 첫번째 Pair클래스는
 public class Pair
{
   /**
      Constructs a pair.
      @param aFirst the first value of the pair
      @param aSecond the second value of the pair
   */
   public Pair(double aFirst, double aSecond) { . . . }

   /**
      Computes the sum of the values of this pair.
      @return the sum of the first and second values
   */
   public double getSum() { . . . }
   . . .
}
이런식이 되야겠구요,
두번째 DataSet 클래스문제는 초기화땐 Integer.MIN_VALUE, Integer.MAX_VALUE 라는 함수를 사용하고, 대소를 구분할땐 Math.max, Math.min함수를 사용하라는 힌트가 주어졌군요,,, if 같은거 쓰지 말래요,,,
그리고 각각 Pair클래스를 테스트하는 PairTester클래스와
DataSet클래스를 테스트하는 DataSetTest클래스도 만들어야 겠네요,,

제가 모든것을 다 설명드릴수는 없지만(검열때문에), dcmichael@nate.com <<네이트온
으로 쪽지주시면 모르는 부분은 좀더 자세히 설명해 드리겠습니다

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편,,,ㅠㅠ  (2) 2009.04.23
JAVA숙제,,,  (1) 2009.04.09
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25

지금 와일리를 보다가 나온건데, 콘솔이 아닌 다이얼로그로 입력, 출력하는법 발견,,

Call the static showInputDialog method of the JOptionPane class, and supply the string that prompts the input from the user. For example,
String input = JOptionPane.showInputDialog("Enter price:");
That method returns a String object. Of course, often you need the input as a number. Use the Integer.parseInt and Double.parseDouble methods to convert the string to a number:
double price = Double.parseDouble(input);
You can also display output in a dialog box:
JOptionPane.showMessageDialog(null, "Price: " + price);
Finally, whenever you call the showInputDialog or showMessageDialog method in a program that does not show any other frame windows, you need to add a line
System.exit(0);
to the end of your main method. The showInputDialog method starts a user interface thread to handle user input. When the main method reaches the end, that thread is still running, and your program won't exit automatically. To force the program to exit, you need to call the exit method of the System class. The parameter of the exit method is the status code of the program. A code of 0 denotes successful completion; you can use nonzero status codes to denote various error conditions.
                                                              (원문 출처 와일리,,,)

이 장에 의하면
JOptionPane.showInputDialog("Enter price:");
이 함수는 Enter Price:라는 문구가 들어간 입력 다이얼로그를 띄워주고 다이얼로그에서 확인이 눌리거나 엔터가 쳐질경우 그 값을 srting 형으로 반환합니다.
그 뒤 Double.parseDouble(string)이나 Int.parseInt(string)함수로 각각의 형으로 고칠수 있는것 같구요,,,,
근데 이거를 사용하면 main함수 마지막에
system.exit(0);을 꼭 써야 한다네요,,,

'대학생활 > JAVA' 카테고리의 다른 글

JAVA숙제,,,  (1) 2009.04.09
4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23

계속 이어서 Arithmetic Operations and Mathematical Functions, Calling Static Methods, Strings, Reading Input 에 대해 설명할께,,,

일단 Arithmetic Operations and Mathematical Functions 요놈,,,
Arithmetic Operations는 산술적인 연산자 + - * / ()설명인데,,, 수학하고 같으니 PASS!!
Mathematical Functions는
Math.sqrt(x)
Square root of x (≥0)
Math.pow(x, y)
xy (x > 0, or x = 0 and y > 0, or x < 0 and y is an integer)
Math.sin(x)
Sine of x (x in radians)
Math.cos(x)
Cosine of x
Math.tan(x)
Tangent of x
Math.asin(x)
Arc sine (sin-1x ε [-π/2, π/2], x ε [-1, 1])
Math.acos(x)
Arc cosine (cos-1x ε [0, π], x ε [-1, 1])
Math.atan(x)
Arc tangent (tan-1x ε [-π/2, π/2])
Math.atan2(y, x)
Arc tangent (tan-1y/x ε [-π, π]), x may be 0
Math.toRadians(x)
Convert x degrees to radians (i.e., returns x · π/180)
Math.toDegrees(x)
Convert x radians to degrees (i.e., returns x · 180/π)
Math.exp(x)
ex
Math.log(x)
Natural log (ln(x), x > 0)
Math.round(x)
Closest integer to x (as a long)
Math.ceil(x)
Smallest integer ≥x (as a double)
Math.floor(x)
Largest integer ≤x (as a double)
Math.abs(x)
Absolute value |x|
Math.max(x, y)
The larger of x and y
Math.min(x, y)
The smaller of x and y
                                                                            (출처 와일리,,,,,)
이거 있다고,, 그냥 그렇다고,,,

그다음은 Calling Static Methods
이건,,,,
int x=4;
double rootofx = x.sqrt();
이렇게 삽질하지 말고
double rootofx = Math.sqrt(x);
이렇게 하래,,,

Strings
String 클래스에는 substr및 각종함수들이 준비되어 있어서 문자열을 사용하기 편하다,,
라는,,,,,,,

이번엔 중요한 Reading Input!!!
C++은 인풋을 읽어오기가 쉬워서 숙제에도 가끔 인풋이 필요했지만,,,
자바는 없었지? 드디어 나왔어 인풋 받는법,,,

Scanner in = new Scanner(System.in);
이렇게 하면 인풋을 받는 스트림이 생긴거야.
그 다음엔
system.out.print("input number : ");
int quantity = in.nextInt();
이렇게 하면 input number : 뒤에 커서가 깜박인데,,, 거기에 숫자를 쓴다음 엔터를 치면quantity에 들어간다는데,,, 지금 컴을 포맷해서 아직 테스트는,,,,

그다음 in.nextInt() 대신 in.nextDouble();을 쓰면 double를 받아오고,,,in.nextLine(); 하면 한 줄(엔터까지) 받아서 string으로,,,in.next(); 까지만 해도 string으로 받는 다는데, 이건 아마 스페이스바가 구분자인가봐,,,
일단 예제,,(출처 와일리 교재 내부,,)

1 import java.util.Scanner;
2
3  /**
4    This program simulates a transaction in which a user pays for an item
5    and receives change.
6    */
7    public class CashRegisterSimulator
8    {
9       public static void main(String[] args)
10      {
11     Scanner in = new Scanner(System.in);
12
13     CashRegister register = new CashRegister();
14
15     System.out.print(“Enter price: ”);
16     double price = in.nextDouble();
17     register.recordPurchase(price);
18
19     System.out.print(“Enter dollars: ”);
20     int dollars = in.nextInt();
21     System.out.print(“Enter quarters: ”);
22     int quarters = in.nextInt();
23     System.out.print(“Enter dimes: ”);
24     int dimes = in.nextInt();
25     System.out.print(“Enter nickels: ”);
26     int nickels = in.nextInt();
27     System.out.print(“Enter pennies: ”);
28     int pennies = in.nextInt();
29     register.enterPayment(dollars, quarters, dimes, nickels, pennies);
30
31     System.out.print(“Your change: ”);
32     System.out.println(register.giveChange());
33      }
34 }

register클래스가 뭔진 몰라도 돈을 입력받을수 있는 클래스인가봐,,,
여하간 여기서 중요한건 register가 아니라 Scanner in 의 용법이니까
실행이 안되면 눈으로 라도 보고,,, 용법만이라도 익혀,,, 근데 아마 저거 다 클럽에 있던,,,
내가 블로그에 퍼놓은  헤더파일에 있는예제인듯

'대학생활 > JAVA' 카테고리의 다른 글

4주차 자바숙제 떳어요,,  (0) 2009.04.01
내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23
내맘대로 강좌 JAVA편 2  (0) 2009.03.16

정말 자바강좌는 나도 공부하며 쓰려니까 쓰기가 어렵군,,,

우선 클래스가 무엇인지와 변수가 무엇인지에 대해 대략 설명은 한것 같은데,,,
좀더 자세한 부분을 설명하도록 할께,,

우선
와일리의 쳅터 4의 목차를 보면
        Syntax 4.1: Cast
        Advanced Topic 4.1: Big Numbers
        Advanced Topic 4.2: Binary Numbers
        Random Fact 4.1: The Pentium Floating-Point Bug
        4.2. Constants
        Syntax 4.2: Constant Definition
        Quality Tip 4.1: Do Not Use Magic Numbers
        Quality Tip 4.2: Choose Descriptive Variable Names
        4.3. Assignment, Increment, and Decrement
        Productivity Hint 4.1: Avoid Unstable Layout
        Advanced Topic 4.3: Combining Assignment and Arithmetic
        4.4. Arithmetic Operations and Mathematical Functions
        Common Error 4.1: Integer Division
        Common Error 4.2: Unbalanced Parentheses
        Quality Tip 4.3: White Space
        Quality Tip 4.4: Factor Out Common Code
        4.5. Calling Static Methods
        Syntax 4.3: Static Method Call
        Common Error 4.3: Roundoff Errors
        How To 4.1: Carrying Out Computations
        4.6. Strings
        Productivity Hint 4.2: Reading Exception Reports
        Advanced Topic 4.4: Escape Sequences
        Advanced Topic 4.5: Strings and the Char Type
        Random Fact 4.2: International Alphabets
        4.7. Reading Input
        Advanced Topic 4.6: Formatting Numbers
        Advanced Topic 4.7: Using Dialog Boxes for Input and Output
        4.8. Chapter Summary
        Classes, Objects, and Methods Introduced in this Chapter
        Review Exercises
        Programming Exercises
        Programming Projects
        Answers to Self-Check Questions
        Further Reading
이렇게 되어있어,,, 중요한거는 4.x부분인데,,,
보면
cast, big number, constants, assignment, Increment, and Decrement, Arithmetic Operations and Mathematical Functions, Calling Static Methods, Strings, Reading Input
이 있어,,헉헉

cast 라는것은 형을 변환 시키는 거야. 예를들면,

double dValue=3.5;
int iValue = (int)dValue; 이렇게 하면 dValue 가 int 형으로 바뀌어서 들어가는거야,,
근데 이상하지? 3.5는 정수가 아닌데 어떻게 될까?
1. 반올림
2. 버림
3. 올림




답은 2번 버림,,,, 소숫점은 무조건 버려, 그럼 int를 double에 넣을땐?
상관없지 뭐,, 그땐 오류없이 잘 들어가,,
이런식으로 형을 변환시키는 것을 형변환(casting)이라고 해. 나중에 클래스끼리도 캐스팅이 되긴 하는데, 이거는 서로 부모, 자식 관계가 있는경우에만 되니까 나중에 설명할께,,

그다음으로는 big number인데,, 와일리에 보면 math라는 클래스안에 BigInterger 랑 BigDecimal 클래스가 있어서 큰수 계산이 된데,,,,

다음은 상수(constants)
인데 상수는 C나 C++언어를 배운 사람은 const예약어를 사용한다고 알고있을거야.
하지만 C++의 클래스에서도 사용했듯이 자바는 final이라는 예약어를 사용해.

예를 들면

final double PI = 3.14;
// PI=3.141592             //에러,,,
double radian = 3;
double area=radian*radian*PI;

이런식으로 PI값은 항상 정해져있어서 고쳐지면 안될때 사용하는거,,,
이게바로 상수의 사용법

그다음은 assignment, Increment, and Decrement

이거는 대입과 증가 감소인데,,,

대입은 계속 해왔고,,,
증가와 감소가 있는데,,
int i=0;
i=i+1;         //1
i+=1;         //2
i++;          //3
system.out.println(i);


결과는 3
왜냐하면 1번은 쉽게 알수있는거고,
2번은 1번을 줄여서 쓸수있게 한거고,,
3번은 i에 1을 더하라는거야,, 그래도 i+++한다고 2가 더해진다는 생각은 버려!!

근데 신기한게,,,
int i=0;
system.out.println(++i);
system.out.println(i++);
이렇게 하면 1하고 1이 출력되,

왜냐하면 ++i는 +1을 한 다음 함수라든지 대입을 하고,
 i++은 대입이나 함수에 먼저 처리를 한다음 +1을 하기 때문,,,헥헥,,, 다음은 뒷글에 이어서,,,

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편 4.5편!!  (0) 2009.03.25
내맘대로 강좌 JAVA편 4  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23
내맘대로 강좌 JAVA편 2  (0) 2009.03.16
내맘대로 강좌 JAVA편 1  (3) 2009.03.16
내용은
Implement a class Student. For the purpose of this exercise, a student has a name and a total quiz score. Supply an appropriate constructor and methods getName(), addQuiz(int score), getTotalScore(), and getAverageScore(). To compute the latter, you also need to store the number of quizzes that the student took. Supply a StudentTester class that tests all methods.

Use the following class as your tester class:
/**
   This program tests the Student class.
*/
public class StudentTester
{
   public static void main(String[] args)
   {
      Student student = new Student("Cracker, Carla");

      // TODO: Add some quizzes

      // TODO: Print actual and expected name, total score
  }
}
Complete the following class in your solution:
/**
   A student who is taking quizzes.
*/
public class Student
{ 
   /**
      Constructs a student with a given name.
      @param n the name
   */
   public Student(String n)
   {  
      . . .
   }

   /**
      Gets the name of this student.
      @return the name
   */
   public String getName()
   {  
      . . .
   }

   /**
      Adds a quiz score.
      @param score the score to add
   */
   public void addQuiz(int score)
   {  
      . . .
   }

   /**
      Gets the sum of all quiz scores.
      @return the total score
   */
   public double getTotalScore()
   {  
      . . .
   }
   
   /**
       Gets the average of all quiz scores.
       @return the average score
   */
   public double getAverageScore()
   {  
      . . .
   }
   . . .
}
 
이렇게 길지만 1문제라는거^^ 처음부분만 잘읽으면 할수 있을거에요,,
그리고 자바강좌가 안올라오는건 저도 자바를 잘 몰라서 공부중이거든요 ^^a
어쨌든 열심히 해서 낙오자 없이 모두 S 받자고요

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
내맘대로 강좌 JAVA편 2  (0) 2009.03.16
내맘대로 강좌 JAVA편 1  (3) 2009.03.16
2주차 JAVA숙제,,,(파일 삭제)  (0) 2009.03.15

빨리하고 물리 보고서 써야 되는데,,,

Rectangle box = new Rectangle(5, 10, 20, 30);
이것이 뜻하는 것은,

Rectangle box 먼저 Rectangle 클래스대로 box개체의 공간을 할당 받는거야.

근데 공간만 있지 거기에 내용이 없잖아? 그래서

new Rectangle(5, 10, 20, 30)
라고 새로운 (5,10)에 위치하고 (가로 X 세로) = (20 X 30)인 직사각형을 만드는거야.

그다음에 Rectangle클래스에 있는 get뭐시기 메소드를 이용하면 가로 세로 x y를 모두 구할수 있어

예를 들면

System.out.println(box.getwidth);
하면 아마 20이 출력될꺼야.

이런식으로 하는거지,,,
나머지는 직접 읽어봐도 간단한 설명과 예제니까 직접 wiley를 읽어 보라고 안그러면 license값이 아깝잖아?

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23
내맘대로 강좌 JAVA편 1  (3) 2009.03.16
2주차 JAVA숙제,,,(파일 삭제)  (0) 2009.03.15

물리 보고서 써야되는데,,,

우선 이것도 Chapter 1~2의 내용을 정리해 볼게,,,

Chapter 1. Introduction

이거는 간단히 프로그래밍이란 이런것이다... 니까 PASS!!

그래서 Chapter 2. using object로 넘어갈께,,

여기서는 "In Java, every value has a type" 이 말로 Chapter를 시작하지.

뭐 모든 프로그래밍 언어가 그렇지만 Java에서는 모든 value에는 type라는 형식을 매겨,

int, String, double등

int는 interger의 약자(?)로 정수형, String은 문자열 Class, double는 배정도 실수형이야.

그리고 JAVA는 본격적인 OOP 언어 답게 모든것을 Class단위로 처리해서

int luckyNumber;
luckyNumber = 13;
System.out.println(luckyNumber);
이런 소스가 나와
먼저
int luckyNumber;
이건 luckyNumber라는 정수형 변수를 선언하는거, 그밑에 luckyNumber = 13;이거는 13을 대입하라는거야,
그리고
System.out.println(luckyNumber);
이거는 System.out개체의 println메소드를 사용해서 luckyNumber변수의 값을 출력하라는거야.
근데 System.out.println 여기까지 쓰면 밑에나 옆에 "System.out.println(int 뭐시기)"라고 상자가 뜨고 거기에보면
"System.out.println(String 뭐시기)"도 있고 같은이름에 괄호속만 다른 뭐가 잔뜩 보이지?

이게 다 하나의 type에는 다른 type가 못들어 가거든? 그때 같은이름으로 다른 type도 받아들이기 위해 여러가지를 만든건데,, 이건 또 나중에,,,

"Objects are entities in your program that you manipulate by calling methods."

 이 말은 개체에는 메소드가 들어있다,,, 라고만 알면 되.

개체란 OOP의 기본인데, 사람이 움직이는것을 표현하는 프로그램을 만드는데,

사람의 손도 움직이고 발도 움직이고 해야 하잖아. 그리고 사람이 1사람이 아니면 여러개를 만들어야 하지?

이런 불편함을 없애기 위해서 사람class 를 만들어 놓고 사람A개체를 만들어서 사람A의 손을 움직여라

사람B의 손을 움직여라. 이렇게 하는거야. 이때 "사람A"는 개체  "손"은 데이터 "움직여라" 는 메소드가 되는거야

그래서 사람A.움직여라(손,15˚); 하면 사람A개체의 손이 15˚만큼 움직이게 되는거지.

그다음에 나오는것은 Method Parameters and Return Values인데,

Method Parameters 라는것은 아까 움직여라 메소드에 준 "손,15˚"을 뜻하는거고 Return Values는 수학의 함수값이라고 생각하면되.

수학에서 f(x)=y라고 하면 f는 메소드 x는 파라메터 y는 리턴값이지.

그다음 가장 중요한거는 오브젝트 생성인것 같은데,, 방법은 간단해. 원하는 클래스를 import한뒤에

Rectangle box = new Rectangle(5, 10, 20, 30);
이런식으로 생성하면 되.
 

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23
내맘대로 강좌 JAVA편 2  (0) 2009.03.16
2주차 JAVA숙제,,,(파일 삭제)  (0) 2009.03.15

You are supposed to make two simple programs in this week.

1. Based on the rectangle class example in our text book, add "intersection method" to the rectangle class. The intersection method returns the intersection of two rectangles, that is the rectangle formed by two overlapping rectangles.

You call this method as follows:

Rectangle r3 = r1.intersection(r2);

r3 is the intersection rectangle formed by r1 and r2.

Write a program IntersectionPrinter that constructs two rectangle objects, prints them, and then prints the rectangle object that describes the intersection. Then the program should print the result of the intersection method when the rectangles do not overlap. Add a comment to your program that explains how you can tell whether the resulting rectangle is empty.

2. Write a program HollePrinter that switches the letters "e" and "o" in a string. Use the replace method repeatedly. You don't need to get inputs from console or GUI. Place the input in your code (For example String input = "Hello, World"). Demonstrate that the string "Hello, World!" turns into "Holle, Werld!".

내용은 요렇게,,,

역시 파일은 여기(였는데,,, due가 넘어가는바람에 검열당한,,,)

'대학생활 > JAVA' 카테고리의 다른 글

내맘대로 강좌 JAVA편 4  (0) 2009.03.25
내맘대로 강좌 JAVA편 3  (0) 2009.03.25
3주차 JAVA숙제가 나왔습니다^^  (2) 2009.03.23
내맘대로 강좌 JAVA편 2  (0) 2009.03.16
내맘대로 강좌 JAVA편 1  (3) 2009.03.16