RichardSmith
New member
היום, ילדים, נלמד לתכנת! ../images/Emo13.gif
import java.awt.*; public class human extends javax.swing.JApplet{ public void paint (Graphics h) { //Body h.drawLine(50,50,50,100); //Legs h.drawLine(70,130,50,100); h.drawLine(30,130,50,100); //Hands h.drawLine(50,60,70,75); h.drawLine(50,60,30,75); //Head h.drawOval(40, 30, 20, 20); //My name h.drawString("Adam Lev Ari", 15, 150); //My Department & year h.drawString("Math, 2nd year", 10, 160); // My favorite book - which is rather taugh... h.drawString("Schrodinger's Cat", 5, 170); //http://www.amazon.com/Schrodingers-Cat-Trilogy-Universe-Pigeons/dp/0440500702/ref=pd_sim_b_1/002-3891103-3151249 // //My favorite movie - which is too rather taugh... h.drawString("Space Balls", 15, 180); //http://www.imdb.com/title/tt0094012/ - A nice one. } }
זאת applet בג'אווה, תוכנה קצרה ומיותרת כחלק משיעורי הבית שלי בקורס תכנות. ועכשיו להסבר: שורה הקוראת לפקודות נוספות מ"ספריות" אחרות.import java.awt.*;
תחילת המחלקה - CLASS, כל קובץ בג'אווה הוא מחלקה משל עצמו.public class human extends javax.swing.JApplet{
בשורה הזו אנחנו מכריזים על תחילת התוכנית עצמה. התוכנית מהווה חלק מהמחלקה.public void paint (Graphics h) {
// - הערה.//Body
זאת הפקודה לביצוע דברים. h זה המשתנה שהכרזנו עליו בתחילת התוכנית, מודגש. לאחר הנקודה מציינים את הפקודה עצמה, למשל ציור קו.h.drawLine(50,50,50,100); //Legs h.drawLine(70,130,50,100); h.drawLine(30,130,50,100); //Hands h.drawLine(50,60,70,75); h.drawLine(50,60,30,75); //Head h.drawOval(40, 30, 20, 20); //My name h.drawString("Adam Lev Ari", 15, 150); //My Department & year h.drawString("Math, 2nd year", 10, 160); // My favorite book - which is rather taugh... h.drawString("Schrodinger's Cat", 5, 170); //http://www.amazon.com/Schrodingers-Cat-Trilogy-Universe-Pigeons/dp/0440500702/ref=pd_sim_b_1/002-3891103-3151249 // //My favorite movie - which is too rather taugh... h.drawString("Space Balls", 15, 180); //http://www.imdb.com/title/tt0094012/ - A nice one. } }
ולבסוף, תראו את התמונה המצורפת.