CS152 Fall 2021
Computer Programming Fundamentals
Home
Schedule
Syllabus
Style Guidelines
Assignment 4: Classes and Objects
Due: Friday October 8 by the end of the day (11:59pm)
Description
You can choose to work in a 2 person team or on your own for this assignment. If you want to work in a team, please let me know (via email) by the end of the day Monday 10/4. The email should contain the full names and email addresses of the team members.
Create a program with a class that describes a vehicle. The vehicle class should have (at least) the following instance variables: xPosition, yPosition. The vehicle class should have (at least) the following methods: constructor, draw(), move (int xAmount, int yAmount). The class should draw some sort of vehicle (a car, boat, plane, etc.) on the screen.
Your program should allow you to move the vehicle around the screen using your keyboard ('w' for up, 's' for down, 'a' for left, and 'd' for right). This structure is known as the WASD keyboard controller. You will need to use these basic MyFrame.java and MyPanel.java classes in addition to your vehicle class. Here is a sample vehicle class you can start from.
Requirements
Your project should include all of the elements below.
- The screen should be at least 500 pixels by 500 pixels. The dimensions can vary depending upon your program.
- Create a nice background for your vehicle to move around in.
- Create a vehicle class as described above. Start from this sample code.
- The vehicle should consist of at least 5 primitive shapes (ie: ellipses, rectangles, etc.) and lines.
- Your vehicle should be controlled using the w, s, a, and d keys.
- Include the appropriate source code header in your vehicle class. If you are working in a team include information for both team members.
- Carefully read and follow the course Style Guidelines.
- Extra credit (5 points): Your program should prevent your vehicle from moving off of the screen. If you hit the edge of the screen, the vehicle should appear on the other side of the screen. That is, if it moves off of the right side of the screen it should reappear on the left side. If it moves off of the bottom of the screen it should reappear on the top.
What to Hand in:
- Your program. Browse to the src folder inside the project that contains your code. Compress the src folder into a .zip file. Rename this file using the following convention: FirstnameLastnameAssignment4.zip. If you're working in a team use this convention: TeamLastnameLastnameAssignment4.zip.
Upload the zip file to Learn. If you do not know how to create .zip files, check out these instructions for PC and mac OS.
- A paragraph about your project. In Learn, also submit a paragraph about your program and how you designed and implemented it. Include a brief discussion about your experience working on this assignment: what challenges did you encounter? how did you address them? what was hard? what did you learn?