Results 1 to 3 of 3

Thread: assign 105 ball

  1. #1
    Anonymous
    Guest


    assign 105 ball

    เอาปายเรย ขอบคุงรุ่นพี่ที่ทำทิ้งไว้

    [src]
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class Movingball_46270354 extends Canvas implements Runnable
    {
    Random r=new Random();
    int x=r.nextInt(500);
    int y=r.nextInt(500);
    double v=r.nextInt(30)+20;
    double rad=r.nextDouble();
    double dx=v*Math.cos(rad);
    double dy=v*Math.sin(rad);
    int w=10;
    int h=10;
    int a,b,c,d,e,f;
    Color color[]={Color.red,Color.green,Color.blue};
    Color co;
    public void run()
    {
    Frame f =new Frame();
    f.setLayout(new FlowLayout());
    f.addWindowListener(new WindowAdapter()
    {
    public void WindowClosing()
    {
    System.exit(0);
    }
    });
    this.setSize(500,500);
    f.add(this);
    f.pack();
    f.setVisible(true);

    int i=0;
    while(true)
    {
    try
    {
    x+=dx;
    y+=dy;
    if ((x>=500)||(x<0))
    dx = -dx;
    if ((y>=500)||(y<0))
    dy = -dy;
    //co=color[i%3];
    Thread.sleep(50);
    i++;
    repaint();
    }
    catch(InterruptedException ex){}
    }
    }
    public void paint(Graphics g)
    {
    {
    //a=r.nextInt(500);
    //b =r.nextInt(300);
    g.setColor(Color.red);
    g.fillOval(x,y,30,30);
    }
    }
    public static void main(String[]args)
    {
    Thread t=new Thread(new Movingball_46270354());
    t.start();
    }
    }
    [/src]

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


    Re: assign 105 ball

    น้องครับพี่เข้าใจนะครับว่าน้องหวังดีอยากให้เพื่อนๆที่ไม่เข้าใจการบ้านได้ลองฝึกเขียนก่อนแล้วถ้าติดตรงไหนก็ให้ดูโค้ดนี้ประกอบ แต่บอกตามตรงครับจากประสบการณ์พี่ ไม่ค่อยเห็นครับแบบนั้น ส่วนใหญ่จะ copy&paste กันเลย แทนที่เขาจะได้ประโยชน์จากการที่เราทำแบบนี้กลับกลายเป็นเราทำร้ายเพื่อนนะครับ ถ้าน้องอยากจะช่วยเพื่อนจริงๆพี่อยากจะให้น้องเขียน Comment ในแต่ล่ะบรรทัดอธิบายหน่อยนะครับว่า คำสั่งไหนใช้ทำอะไรคนอื่นเอาไปจะได้ทำความเข้าใจได้
    พี่ไม่อยากเห็นน้องๆ เก่งกันอยู่ไม่กี่คน ช่วยๆกันนะครับ ยังไงก็ขอเป็นกำลังใจให้นะครับสำหรับคนที่ทำเองได้ ส่วนคนที่ copy ก็คงรู้ผลของการกระทำอยู่แล้ว ของแบบนี้ถ้าไม่ใกล้จะจบแล้วไม่รู้สึกหรอกครับ

  3. #3
    Junior Member
    Join Date
    Oct 2002
    Location
    Thailand
    Posts
    0


    Re: assign 105 ball

    การก๊อปโค้ดที่รันได้แล้วเอาไปลองเนี่ย พี่ไม่คิดว่าเสียหายนา
    แต่หลังจากที่มันรันได้แล้วก็เอาไปส่งเนี่ย... มันเสียหลายอย่าง
    1. เสียที่คนก๊อป ไม่ได้ความรู้, หมดความสนใจ
    2. เสียที่คนให้ก๊อป ไปๆมาๆต้องเขียนใหม่อีกรอบ '

    ยังไงพี่ก็ว่าการที่มีโค้ดที่รันได้มาให้ลองเนี่ย มันเป็นเรื่องที่ดีนะ อย่างน้อยมันก็ทำให้คนที่สนใจลองมาแกะโค้ดดูได้

    แต่ว่าเอาไอ้ที่มันใกล้เคียงการบ้านมาจะดีกว่าไหม?

    ปล. รุ่นพวกพี่ตอนนี้กำลังหางานน่ะ เริ่มรู้สึกแล้วว่า เด็ก CS ถึงเกลียดโปรแกรมมิ่งแค่ไหน สุดท้ายก็หนีมันไม่พ้น บางที่อาจจะใช้แค่คอนเซ็ปต์ หรือโลจิค บางที่อาจจะใช้ล้วนๆ แต่เชื่อพี่เหอะ พี่ฟันธงเลยว่ามันจำเป็น

Similar Threads

  1. Replies: 2
    Last Post: 02-12-2008, 09:02 PM
  2. Replies: 1
    Last Post: 19-07-2006, 01:31 AM
  3. Assign 105 : Pict~
    By Anonymous in forum Java
    Replies: 1
    Last Post: 06-11-2004, 05:03 PM
  4. bouncing ball using JApplet
    By kr04t in forum Java
    Replies: 1
    Last Post: 12-12-2003, 06:23 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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