Results 1 to 10 of 10

Thread: ช่วยหน่อยดิ เรื่อง OOP assignment I

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Location
    United States
    Posts
    9


    ช่วยหน่อยดิ เรื่อง OOP assignment I

    คือว่ายังไม่รู้จาทามยางไงดีอะ
    ??? ??? ???
    โขควมซ่วยเหลือโด่นเลย
    อิอิ

    โจทย์ทั่นว่าไว้ดังนี้
    a word count tool
    5 pts
    due next wednesday [13/08/03]
    this program will count a number of words in an inout file. An input file is specified in a command line.

    สั้นๆ แตดุดันเจงๆ พับแผ่

    assignment II
    drawing tools
    10 pts
    due 3 weeks [date amy be 3 or 10/09/03]
    similar to paint program.
    create a drawing window and a set tool (line, rectangle, freehand)
    [Those options may be changed after first assignment is handed in]

    ซ่วยหน่อยเต๊อะ เจ้าข้าเอ๊ย
    :P :wob: :P

  2. #2
    Junior Member
    Join Date
    Nov 2002
    Location
    United States
    Posts
    0


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    อย่างแรกเลยก็ต้องดูก่อนว่าโจทย์ต้องการอะไร
    1.โจทย์ต้องการ input file ผ่าน command line อย่างเช่น
    c:>java count test.txt หรือ
    c:>java count
    please input file : test.txt อย่างใดอย่างนึง
    2.โจทย์ต้องการ นับคำจาก file ที่ input เข้ามา
    จบแล้ว เข้าใจป่ะ

  3. #3
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    เดี๋ยวจะเอาตัวอย่างมาให้ดูนะ

  4. #4
    Junior Member
    Join Date
    Sep 2002
    Location
    United States
    Posts
    9


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    ไม่ค่อยเกตอะ
    ปะมานว่า
    ให้ user ใส่ input
    โยให้เป็นไฟล์เหรอ
    คล้ายๆกะงาน File or อะดิ
    ที่ต้องอ่านจาก input file
    ใช่ปะๆ

    ว่าแต่มีตัวอย่างเร็วๆก็ดีนะทั่น
    :wob: :wob: :wob:

  5. #5
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    [src]

    import java.io.*;

    class FileInputDemo
    {
    public static void main(String args[])
    {
    // เช็คความยาวของ argument ตำแหน่งที่สองว่ายาวเท่ากับ1 ถ้าใช่แสดงว่ามีการระบุชื่อ file นั้นเอง
    if (args.length == 1)
    {
    try
    {
    //ตรวจสอบค่า argument ว่าจะเปิด file อะไร
    System.out.println("define input stream");
    FileInputStream fstream = new
    FileInputStream(args[0]);

    // แปลง input stream เป็น DataInputStream
    DataInputStream in = new DataInputStream(fstream);
    // อ่านข้อความใน file ไปเรื่อยๆ
    while (in.available() !=0)
    {
    //พิมพ์ข้อความใน file ออกหน้าจอ
    System.out.println (in.readLine());
    }

    in.close();
    }
    catch (Exception e)
    {
    System.err.println("File input error");
    }
    }
    else
    System.out.println("Invalid parameters");
    }

    }


    [/src]

    src code ตัวนี้ผมใช้ JCreator เวลาจะรันให้ไปแก้ที่
    1.configure->option->JDK tool
    2.click default แล้ว edit
    3.click ที่หัวข้อ parameter
    4.เลือก ที่ "prompt for main method for arguments"
    5. เวลาโปรแกรม รันมันจะแสดง dialog ให้เรากำหนดค่า argument ที่เราต้องการให้โปรแกรมทำงาน

  6. #6
    Junior Member
    Join Date
    Sep 2002
    Location
    United States
    Posts
    9


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    ขอบคุณสำหรับตัวอย่งนะ
    ว่าแต่มันเปนแบบที่เราพูดถึงปะ
    ที่ว่าให้ user ใส่ input file
    ละให้ปะแกมอ่านจากไฟล์เอา
    ใช่ปะๆ
    ??? ??? ???

  7. #7
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    อธิบายแบบนี้แล้วกันคงเคยเห็นคำสั่ง copy file ใน dos ใช่ไหมที่มันต้องพิมพ์ว่า "copy test.txt a:"
    อะไรทำนองนี้ เจ้าตัวคำสั่ง copy จริงๆมันก็คือ โปรแกรมนั้นแหล่ะ อาจจะเป็น copy.com หรือ copy.exe ที่ execute ได้ส่วนเวลามันจำทำงานมันต้องตามด้วยชื่อ file ใช่ไหม ไอ้ตัวนี้แหล่ะที่ทำหน้าที่เป็น input ให้กับโปรแกรม ซึ่งใน java จะใช้ส่วนนี้แทนว่า args[0]

    คงจะสงสัยอีกว่าทำไมต้องทำเป็นแบบ array เหตุผลเพราะเพื่อความยืดหยุ่นนั้นเอง จะได้เปิด file อื่นๆ ได้ตามที่จะระบุมา

  8. #8
    Junior Member
    Join Date
    Sep 2002
    Location
    United States
    Posts
    9


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    เหมือนจะเข้าใจ
    ต้องเริ่มลงมือในวันพุ่งนี้ละไม่ง้าน
    หึๆ
    :P
    ไม่ต้องคิด
    :wob: :wob: :wob:

  9. #9
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    ถ้ายังไม่เข้าใจวิธี config JCreator ก็ไปดูที่ section ใหม่นะที่ ด้านบนสุด "See it do it"

  10. #10
    Junior Member
    Join Date
    Sep 2002
    Location
    United States
    Posts
    9


    Re: ช่วยหน่อยดิ เรื่อง OOP assignment I

    ใช้ Eclipse อะ
    แต่มะเปนรายใช้มานทั้ง 2 ตัวก็ได้
    เหอๆ

Similar Threads

  1. Replies: 16
    Last Post: 30-08-2008, 01:00 AM
  2. PHP Multi-line assignment
    By Komkid in forum PHP,ASP,Javascript, Html
    Replies: 0
    Last Post: 24-09-2007, 09:48 AM
  3. NEW Assignment CSC105
    By massiah in forum Java
    Replies: 4
    Last Post: 04-11-2004, 11:37 PM
  4. CSC105 Assignment
    By massiah in forum Java
    Replies: 12
    Last Post: 03-11-2004, 09:54 AM
  5. assignment aj udom
    By armano in forum Announcement
    Replies: 4
    Last Post: 02-03-2003, 06:03 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •