lab 10 Lab 10 I frequently change the lab assignment just before class starts (and sometimes during class). Try not to download the assignment until after class. Please read https://www.plagiarism.org/article/what-is-plagiarism. Code may be copied from the lecture notes or from web pages or from books Copied code MUST include a citation (e.g. URL of the web page where the code is copied from) Code that is copied and then modified MUST include a citation (e.g. URL of the web page where the original code was copied from) Code copied from the lecture notes are not required to have a citation. You may NOT copy answers from another student. You may NOT allow another student to copy your answers. You may NOT turn in a team solution (e.g. 2 or more people work on the lab together and turn in multiple copies of the same lab). Help is available by: READING THE LECTURE NOTES! USING THE UML-LIKE DIAGRAMS! coming to a lab session (available only for in-person or zoom classes) visiting the Magic Lab (https://www.mjc.edu/instruction/bbss/magic.php) using Google or YouTube sending me an e-mail posting a note on the Canvas Q/A Discussion Board and hope that a student will write a response sometimes a FREE tutor is available from the Library and Learning Center join a study group OR gather up some folks and start your own study group In this lab, you are going to practice using the Java language to write graphic primitives. To help you display your graphic artwork on the screen, I wrote Game.java To get Game.java, download game.zip. After downloading game.zip, right click the game.zip and select Extract All. For each task, you are to: 1) Open Game.java in a text editor. Find the method: public void paintFrame(Graphics g) { /* Type your code here */ } 2) replace the line"/* Type your code here */" with one or more lines of code YOU typed. YOUR code will draw one or more graphic primitives. 3) compile Game.java 4) run Game.java The following cheat sheet might be useful. Graphics void drawLine(int x1, int y1, int x2, int y2) //2 dots void drawRect(int x, int y, int width, int height) //upper left corner void drawOval(int x, int y, int width, int height) //bounding box void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) //0 is east, 90 is north void drawPolygon(int[] x, int[] y, int numberOfPoints) //vertices Example: g.drawPolygon(new int[]{10,20,30}, new int[]{30,10,30}, 3); void drawString(String str, int x, int y) //left edge of baseline void setFont(Font font) NOTE: Font font = new Font("Dialog", Font.PLAIN, 12) //PLAIN, BOLD, ITALIC void setColor(Color color) //e.g. Color.BLACK void drawImage(Image image, int x, int y, ImageObserver observer) //upper left corner NOTE: Image image = new ImageIcon("cat.gif").getImage( ) task 1: Create a folder named task1. Download game.zip. Unzip game.zip. Copy the Game folder into the task1 folder. Modify Game.java so that game displays a happy face on the screen. Only graphic primitives should be used; images may NOT be used. I drew this with a paint editor. Your happy face will look every different. Begin photo happy face End photo Do NOT change the name of the Game.java file Compile Game.java Run Game.java If you encounter coding errors, then do this: Repeat until all errors are fixed Find the first error (the error at the very top of the list of errors) Fix ONLY the first error. Do NOT fix any other errors. Try running the code Get a screenshot of the screen while the code is running. I want to see a happy face. Crop the screenshot. Place the screenshot into the task1 folder. CHECK YOUR CANVAS SUBMISSION!!!! insert a blank USB drive into your computer log on to Canvas go to the lab assignment download your submitted files put your downloaded submitted files onto your USB flash drive Folks, who are using Netbeans, should launch Netbeans, open the NetBeans project that is on the USB flash drive, and run the code. Folks, who are using the command line, should launch command console, go to the USB flash drive, compile their .java file, and run their .java file See How To Avoid The Potholes When Submitting a Lab for additional information. To grade this task, I will compile and run your code. If no code is turned in, then I won't be able to grade this lab. If the code doesn't compile, then I won't be able to grade this lab. If the code doesn't run, then I won't be able to grade this lab. task 2: Create a folder named task2. Download game.zip. Unzip game.zip. Copy the Game folder into the task2 folder. Modify Game.java so that game displays a house on the screen. Only graphic primitives should be used; images may NOT be used. Modify Game.java so that game displays a house on the screen. Your house should have: 2 or more walls a triangle roof one or more doors 2 or more windows Only graphic primitives should be used; images may NOT be used. Your house may look very different. Do NOT change the name of the Game.java file. Compile Game.java Run Game.java If you encounter coding errors, then do this: Repeat until all errors are fixed Find the first error (the error at the very top of the list of errors) Fix ONLY the first error. Do NOT fix any other errors. Try running the code Get a screenshot of the screen while the code is running. I want to see a house. Crop the screenshot. Place the screenshot into the task2 folder. CHECK YOUR CANVAS SUBMISSION!!!! insert a blank USB drive into your computer log on to Canvas go to the lab assignment download your submitted files put your downloaded submitted files onto your USB flash drive Folks, who are using Netbeans, should launch Netbeans, open the NetBeans project that is on the USB flash drive, and run the code. Folks, who are using the command line, should launch command console, go to the USB flash drive, compile their .java file, and run their .java file See How To Avoid The Potholes When Submitting a Lab for additional information. To grade this task, I will compile and run your code. If no code is turned in, then I won't be able to grade this lab. If the code doesn't compile, then I won't be able to grade this lab. If the code doesn't run, then I won't be able to grade this lab. Folks who need a working Java development environment, can read this: How to install and use Java on the command line. This is the quickest, easiest, and most fool-proof way to set up a Java development environment. Help for the totally lost Install Netbeans. http://walshe.faculty.mjc.edu/Virtual/IntroToProgramming/HowTo/HowToInstallNetBeansAndjava/HowToInstallNetBeansAndJava.html Insert Game.zip into a NetBeans project: http://walshe.faculty.mjc.edu/Virtual/IntroToProgramming/HowTo/HowToInsertTheGameProjectIntoNetBeans.pdf In Netbeans, preform these tasks: double click Game.java to pop up an editor scroll down until you see "type your code here" go through the lecture notes to find example source code on how to draw a circle copy-and-paste that code below the line "type your code here" run the code If the Java compiler displays a long list of coding errors, then read only the first error, fix ONLY the first error, then run the code again. NOTE: DO NOT IGNORE ERRORS. ALWAYS READ AND FIX ONLY THE FIRST ERROR!!!!! Once the code is working, change the code: resize the circle to the size you want move the circle to where you want it Run the code. Fix all errors. Change the code: write the code to draw a circle for the left eye change the size of the circle change the location of the circle Run the code. Fix all errors. Change the code: write the code draw a circle for the right eye change the size of the circle change the location of the circle Run the code. Fix all errors. Search the lecture notes for example code on how to draw an arc Change the code: copy-and-paste that code into Game.java change the size of the arc change the location of the arc change the start angle of the arc change the arc-width Run the code. Fix all errors. Deliverables: For each task: task folder or a zip file of the task folder screenshot You may, if you want to, turn in one zip file that contains all the files. Do NOT use 7z nor rar nor tar nor tar.gz. I STRONGLY recommend checking your Canvas submission: insert a blank USB flash drive into your computer launch Canvas download your uploaded files onto the USB flash drive run your uploaded java files and verify the output looks ok see How To Avoid The Potholes When Submitting a Lab for additional information