<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Array Lists - CSCI 151: Data Structures</title><link>https://cs.oberlin.edu/~cs151/lab-3/index.html</link><description>Lab 3 Goals Implement an array list to reinforce our understanding how it works Practice using unit tests to help us debug our code Explore the application of array lists for a real-world problem Welcome to your third CSCI 151 lab! The lab can be started by following this link to create a copy of the assignment for you on GitHub: Accept Assignment
In this week’s lab, we will be exploring the array list data structure by (1) creating our own implementation to better understand how it adds flexibility to the more rigid array data type, and (2) exploring its use in a real-world application of maintaining a searchable contact list for faculty and staff on campus (to help you find offices of people in the College). We will also gain practice using unit tests for testing our code piecewise as we develop it (rather than waiting until we’ve written a lot of intertwined code that is difficult to debug).</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-3/index.xml" rel="self" type="application/rss+xml"/><item><title>Testing</title><link>https://cs.oberlin.edu/~cs151/lab-3/w-part-1/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/w-part-1/index.html</guid><description>From now on, we will be developing unit tests for all of our code. Unit testing is widely used in the software industry to create automated tests to make sure the methods you have created work correctly before you use them in larger projects. Writing extensive unit tests early will save you a lot of time debugging later on.
In order to be able to create tests for our code, we will need to make sure to open the lab folder, rather than just a single file. So before you begin, make sure you open the Lab 3 folder in VS Code and can see all your files in the explorer window.</description></item><item><title>Debugging</title><link>https://cs.oberlin.edu/~cs151/lab-3/w-part-2/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/w-part-2/index.html</guid><description>It’s now time to debug what went wrong. For that, we can use the debugger. Find the line of the assertion that failed. Double click on the dot next to the line number. This will cause a small red dot to appear to the left of the line number. This indicates a breakpoint. When you run the code in a debugger, each time a breakpoint is reached, the debugger will stop and give you control.</description></item><item><title>Remaining Tests</title><link>https://cs.oberlin.edu/~cs151/lab-3/w-part-3/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/w-part-3/index.html</guid><description>Now, we will write tests for the contains method. Since contains returns a boolean, we can use the AssertTrue and AssertFalse checks to test it. In the testContains method, write a test that creates a new Dataset and adds several values, including 3.0 but not including 1.0. Now, try adding the following assertions:
assertTrue(ds.contains(3.0)); assertFalse(ds.contains(1.0)); Play around with different values to make sure that your tests are working correctly.</description></item><item><title>Exceptions</title><link>https://cs.oberlin.edu/~cs151/lab-3/w-part-4/index.html</link><pubDate>Sat, 07 Aug 2021 09:07:24 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/w-part-4/index.html</guid><description>Finally, we need to handle some exceptional cases. What happens if we call max(), min(), mean(), or median() if the DataSet is empty? We need some way to tell anyone using our DataSet that those methods shouldn’t be called on an empty DataSet. The way to do this in Java is to throw an exception.
Let’s change that behavior to throw an IllegalStateException if the DataSet is empty. Add the following code to the beginning of each of those four methods in DataSet.java</description></item><item><title>Starting MyArrayList</title><link>https://cs.oberlin.edu/~cs151/lab-3/l-part-1/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/l-part-1/index.html</guid><description>Data Structure Overview As discussed in class, Java already provides an interface called List that defines all the methods that an array list should have, as well as an AbstractList abstract class that implements some of the basic functionality of the List interface (that could be shared by other types of lists that are not backed by an array). This is similar to how Lab 2 provided a Player interface that defined all the methods a player in the Go Fish game should have, and you created an AbstractPlayer abstract class that defined the shared functionality of different kinds of players.</description></item><item><title>Inserting and Retrieving Items</title><link>https://cs.oberlin.edu/~cs151/lab-3/l-part-2/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/l-part-2/index.html</guid><description>Overview In this part of the lab, we will add functionality to our MyArrayList class to insert and retrieve items from our data structure. We will also practice using unit tests to debug and validate our implementation.
Adding Items to MyArrayList The first main operation we will work on programming is adding items to our data structure since we cannot do anything unless it is storing data. Given how array lists store data, we need to first create a private helper method that will make sure our add methods for inserting data always work.</description></item><item><title>Replacing and Removing Items</title><link>https://cs.oberlin.edu/~cs151/lab-3/l-part-3/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/l-part-3/index.html</guid><description>Overview In this part of the lab, we will add the remaining functionality to our MyArrayList class to replace and remove items from our data structure, as well as a few methods for affecting the current state of the data structure. We will also continue practicing using unit tests to debug and validate our implementation.
Replacing Items in MyArrayList Sometimes when working with an array list, we want to replace an item that is currently stored so that the new item is now at the index of the former item. For this, we will use the public T set(int index, T item) method, which should:</description></item><item><title>Contact List Application</title><link>https://cs.oberlin.edu/~cs151/lab-3/l-part-4/index.html</link><pubDate>Sun, 13 Jun 2021 17:08:08 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/l-part-4/index.html</guid><description>There are many faculty and staff on campus who you might want to interact with, but finding everyone can be a challenge! In this part of the lab, we will create an application that creates a list of contact information for each faculty and staff member in the College including their office number, then we will use that list to allow users to look up peoples’ office numbers based on their names.</description></item><item><title>Wrap Up</title><link>https://cs.oberlin.edu/~cs151/lab-3/wrap-up/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/wrap-up/index.html</guid><description>Congratulations! You have now implmented our first data structure (the Array List) and created an application using it to complete your third 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><item><title>Testing Not Working</title><link>https://cs.oberlin.edu/~cs151/lab-3/help/index.html</link><pubDate>Fri, 06 Aug 2021 20:21:56 -0400</pubDate><guid>https://cs.oberlin.edu/~cs151/lab-3/help/index.html</guid><description>If generate tests is not working on your machine try the following solutions to see if they help Quit and re-open VS-Code Clean the language server Click the search bar at the top of VS-Code Click Show and Run Commands Type Java: Clean Java Language Server Workspace Entirely restart the machine If your tests exist but you get an error If your error is Failed to get workspace folder from test item Inside VS-Code, click File &gt; Open Folder. Look at the top of the pop up that comes up and click the arrow circled below. It will say one of two things. /usr/users/quota/students/ followed by a year and your obieID OR /zfs/students/ followed by your username. If it starts with usr, you are in a simlinked version of your lab, which can cause problems. Follow the rest of these steps. If it starts with zfs, you are in the correct place. Try the steps for generate tests not working, and then ask your instructor for help. Write down the year your folder is in Click the disk drive image to the left of usr. Open the zfs folder, then the year you wrote down then find your ObieID and open that folder. Then click open in the top right. You should now be able to run your tests (you may need to close and re-open VS-Code for this to work) If none of the above work, please talk to your instructor and/or Lab Manager.</description></item></channel></rss>