<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Object-Oriented Programming - CSCI 151: Data Structures</title><link>https://cs.oberlin.edu/~cs151/lab-2/index.html</link><description>Lab 2 Goals Create Java programs using object-oriented programming (OOP) Create and manage arrays to store dynamically changing data Model different strategies for playing the card game Go Fish Welcome to your second CSCI 151 lab! The lab can be started by following this link to create a copy of the assignment for you on GitHub Classroom: Accept Assignment
In this week’s lab, we will be exploring object-oriented programming principles such as encapsulation and inheritance, exploring the use of arrays as a data structure, and continuing to refine our Java programming skills.</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sat, 07 Aug 2021 09:07:24 -0400</lastBuildDate><atom:link href="https://cs.oberlin.edu/~cs151/lab-2/index.xml" rel="self" type="application/rss+xml"/><item><title>Using the Terminal</title><link>https://cs.oberlin.edu/~cs151/lab-2/w-part-1/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/w-part-1/index.html</guid><description>Just like last lab, you will start this lab by creating a GitHub repository by clicking on the link on the home page of this lab.
Go to github.com and navigate to your list of repositories. Once the lab 2 repository is created, you’ll need to use git clone to copy the files to this computer. Just like last time, open the terminal and type
git clone XXXX where XXXX is the repository address that you copy from the CODE button on the GitHub page for the repository.</description></item><item><title>Arrays</title><link>https://cs.oberlin.edu/~cs151/lab-2/w-part-2/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/w-part-2/index.html</guid><description>In this part, we’re going to learn how to create and use arrays. Arrays are very similar to lists in Python except they have a fixed size and they’re homogeneous, meaning all elements have the same type.
Open the file Arrays.java in your repository using Visual Studio Code. You can refer back to Lab 1 if you need a refresher of how to do so.
Inside main, create a new array of ints of length 15:</description></item><item><title>Working with Classes</title><link>https://cs.oberlin.edu/~cs151/lab-2/w-part-3/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/w-part-3/index.html</guid><description>1. Starting a Dog Park Open Dog.java and take a look at the code with a partner. Discuss what the code does.
Open Park.java. Add code to the main method that does the following:
Creates an array of two different dogs Uses a for loop to loop through the array and make both dogs speak Uses a for loop to loop through the array and make both dogs play Compile and run your code to make sure it works.</description></item><item><title>Card Class</title><link>https://cs.oberlin.edu/~cs151/lab-2/l-part-1/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/l-part-1/index.html</guid><description>Program Overview For this lab, we will be completing a program that plays a two-player version of the card game Go Fish. In this game, each player is dealt an initial hand of cards, then they take turns asking the other player for cards. Players score a “book” whenever they collect four cards of the same rank (i.e., face value), and the winner is the player who accumulates the most books. A more complete description of the rules of the game can be found on Wikipedia.</description></item><item><title>AbstractPlayer Class</title><link>https://cs.oberlin.edu/~cs151/lab-2/l-part-2/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/l-part-2/index.html</guid><description>Overview If we think about how to play the game of Go Fish!, there are certain pieces of information that all players will keep track of, regardless of the strategy they use to try to win the game. Each player will have a hand of cards, as well as a number of books that they have already collected. They also share several actions that they will all have to take, such as adding and removing cards from their hand, and reporting their score at the end of the game to determine the winner. When thinking about object oriented programming, these shared pieces of information and behaviors are excellent candidates for an abstract parent class.</description></item><item><title>RandomPlayer Class</title><link>https://cs.oberlin.edu/~cs151/lab-2/l-part-3/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/l-part-3/index.html</guid><description>Strategy Overview When playing Go Fish, the main decision a player needs to make is what rank to ask the other player for. There are many different strategies players could take here. Some popular ones include:
always asking for the most common rank they have in their hand, which is the most likely to complete a book for the player always asking for the last rank they picked up from the deck when their previous turn ended, which could be the most likely rank to be held by the opponent spread their asks across the numbers they have (maybe in ascending or descending order), which could make it more difficult for the opponent to remember what cards the player is holding What strategy a player follows is the key distinguishing characteristic between different types of Player and represent the different children classes of AbtractPlayer.</description></item><item><title>UserPlayer Class</title><link>https://cs.oberlin.edu/~cs151/lab-2/l-part-4/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/l-part-4/index.html</guid><description>Strategy Overview The second and final type of Player in our game will be one that allows the user to play the game and follow their own preferred strategy. Specifically, it will have the user input a rank to ask of the opponent every turn. In this part of the lab, we will implement a UserPlayer that interacts with the user and is our second child class of AbtractPlayer.
With a UserPlayer you can compete with either a RandomPlayer or another player!</description></item><item><title>Wrap Up</title><link>https://cs.oberlin.edu/~cs151/lab-2/wrap-up/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-2/wrap-up/index.html</guid><description>Congratulations! You have now created several Java programs using Object-Oriented Programming and completed your second lab of the semester!
Filling Out the README.md The final task for every lab is to edit the README file in the lab assignment repository. Each week, you’ll be asked to answer three questions regarding collaboration, time spent on the lab, and the Honor Code.
A reminder to make sure you have consulted the Honor Code policy in the course syllabus for information about how to sign the Honor Code and about acceptable collaboration in CSCI 151. Your instructor is also happy to answer any questions about the Honor Code – just let us know.</description></item></channel></rss>