משחק שלם ואריזה ל-jar ו-jpackageA full game, packed with jar & jpackage
מחברים הכול למשחק שלם, אורזים ל-jar שרץ בלחיצה כפולה, ויוצרים מתקין עם jpackage.
Putting it all into a full game, packing a jar that runs on double-click, and making an installer with jpackage.
כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-IntelliJ ולסמן פתרתי. ההתקדמות נשמרת.Write in each exercise's editor, press Run to see output and Check for the automatic checker. You can also work in IntelliJ and mark I solved it. Progress is saved.
חימום: 3 שאלותWarm-up: 3 questions
תרגיליםExercises
תרגילExercise 1
manifestA manifest
manifest(mainClass, version) בונה את הטקסט של MANIFEST.MF: Manifest-Version: 1.0, Main-Class: Main, Implementation-Version: 1.0.0. הדפיסו אותו.
manifest(mainClass, version) builds the text of MANIFEST.MF: Manifest-Version: 1.0, Main-Class: Main, Implementation-Version: 1.0.0. Print it.
איך הפלט אמור להיראות?What should the output look like?
Manifest-Version: 1.0
Main-Class: Main
Implementation-Version: 1.0.0
Main.java
ההשוואה נעשית בדפדפן מול הפלט האמיתי של הפתרון שלנו. אם הקוד נפל, הדביקו את הודעת השגיאה ותקבלו הסבר.The comparison happens in your browser, against our solution's real output. If the code crashed, paste the error message and get an explanation.
רמזHint 1:כל שורה מסתיימת ב-\n.Each line ends with \n.
Properties קורא קובץ key=value (ומדלג על הערות #). טענו מתוך מחרוזת (בפרויקט: מקובץ ליד ה-jar), והדפיסו Star Catcher 400x300 sound=on fps=60 (fps חסר, ברירת מחדל 60).
Properties reads a key=value file (skipping # comments). Load from a string (in the project: from a file next to the jar), and print Star Catcher 400x300 sound=on fps=60 (fps is missing, default 60).
איך הפלט אמור להיראות?What should the output look like?
Star Catcher 400x300 sound=on fps=60
Main.java
ההשוואה נעשית בדפדפן מול הפלט האמיתי של הפתרון שלנו. אם הקוד נפל, הדביקו את הודעת השגיאה ותקבלו הסבר.The comparison happens in your browser, against our solution's real output. If the code crashed, paste the error message and get an explanation.
כתבו את Game מהתזכורת: מצבים, קלט, משוט מוגבל למסך, כוכב חדש כל 0.6 שנייה (עם Random(seed)), נפילה, תפיסה (10 נקודות) ופספוס (חיים). הריצו עם seed 42 ושחקן אוטומטי עד Game Over, והדפיסו את התוצאה. בבית: חברו ל-JPanel מהמפגשים הקודמים.
Write Game from the refresher: states, input, a paddle kept on screen, a new star every 0.6 seconds (with Random(seed)), falling, catching (10 points) and missing (lives). Run with seed 42 and an automatic player until game over, and print the result. At home: connect it to the JPanel from earlier sessions.
איך הפלט אמור להיראות?What should the output look like?
GAME_OVER score=30 lives=0
Main.java
ההשוואה נעשית בדפדפן מול הפלט האמיתי של הפתרון שלנו. אם הקוד נפל, הדביקו את הודעת השגיאה ותקבלו הסבר.The comparison happens in your browser, against our solution's real output. If the code crashed, paste the error message and get an explanation.
רמזHint 1:עם seed קבוע התוצאה זהה בכל הרצה.With a fixed seed the result is the same every run.
compare(a, b) משווה גרסאות major.minor.patch כמספרים (לא כטקסט: 1.10 אחרי 1.2). הדפיסו -1 1 0.
compare(a, b) compares major.minor.patch versions as numbers (not as text: 1.10 after 1.2). Print -1 1 0.
איך הפלט אמור להיראות?What should the output look like?
-1 1 0
Main.java
ההשוואה נעשית בדפדפן מול הפלט האמיתי של הפתרון שלנו. אם הקוד נפל, הדביקו את הודעת השגיאה ותקבלו הסבר.The comparison happens in your browser, against our solution's real output. If the code crashed, paste the error message and get an explanation.
רמזHint 1:split("\\."): הנקודה מיוחדת ב-regex.split("\\."): the dot is special in a regex.
במחשב שלכם, בתיקיית המשחק: הדרו ל-out, צרו stars.jar עם Main כמחלקה הראשית, הריצו עם java -jar, ואז צרו תוכנה עם jpackage.
On your computer, in the game folder: compile into out, create stars.jar with Main as the main class, run it with java -jar, then make an app with jpackage.
רמזHint 1:ב-Windows jpackage --type exe צריך גם את WiX; app-image עובד בלי.On Windows jpackage --type exe also needs WiX; app-image works without it.
הריצו את Game עם seed 7 ועם seed 42 (אותו שחקן אוטומטי), והדפיסו את שתי התוצאות. הן כנראה שונות, אבל כל אחת קבועה בכל הרצה. זה מה שמאפשר לבדוק משחק עם אקראיות.
Run Game with seed 7 and with seed 42 (the same automatic player), and print both results. They're probably different, but each is fixed on every run. That's what makes a game with randomness testable.
איך הפלט אמור להיראות?What should the output look like?
ההשוואה נעשית בדפדפן מול הפלט האמיתי של הפתרון שלנו. אם הקוד נפל, הדביקו את הודעת השגיאה ותקבלו הסבר.The comparison happens in your browser, against our solution's real output. If the code crashed, paste the error message and get an explanation.
רמזHint 1:שימו את הלולאה במתודה static String play(long seed).Put the loop in a static String play(long seed) method.
הסתכלו בתוך ה-jar: רשימת הקבצים, ותוכן ה-manifest. אחר כך הוסיפו תמונה לתיקיית resources וודאו שהיא נכנסת.
Look inside the jar: the list of files, and the manifest's content. Then add a picture to a resources folder and make sure it goes in.
רמזHint 1:בקוד טוענים תמונה מה-jar עם getClass().getResource("/star.png").In code, load a picture from the jar with getClass().getResource("/star.png").