Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment 1 - ITSC 2214 Fall 2019 Due September 20 th , midnight Extended deadline: September 22 nd , midnight (10% deduction) Objectives At the

Assignment 1 - ITSC 2214 Fall 2019

Due September 20th, midnight

Extended deadline: September 22nd, midnight (10% deduction)

Objectives

At the completion of this assignment, you will have completed an ArrayList implementation of a ShoppingList interface, and completed unit testing of the implementation. By completing this project, you will have gained experience in understanding the difference between interface and implementation, a critical part of encapsulation. You will get experience writing JUnit test cases for methods, to make sure the methods work as expected. You will also become accustomed to the Web-Cat system for auto-grading of code projects and tests. This system may seem frustrating at first, but in industry you will have to check in code that you write to similar systems that will run your code against a bunch of test cases. You can also observe the use of exceptions, how they are passed and handled and how you work with them when writing test cases.

Instructions

During this assignment, you will be working with an interface for shopping lists. We provide a completed array implementation of this interface, and an incomplete ArrayList implementation. Your job is to complete the ArrayList implementation. Both implementations adhere to the ShoppingListADT interface. The shopping lists hold Grocery items, and there is a Grocery class that defines what a Grocery item is. While duplicate grocery items are not allowed in the list, the quantities of a grocery item are combined when an attempt is made to add a duplicate Grocery. Through the Grocery classs compareTo method, entries are determined as duplicates if their name and category match, regardless of letter case (ie. bread is the same as Bread).

Requirements

You must fulfill the following requirements in your implementation.

  1. Complete the three empty methods (remove(), find(), and contains()) in the ShoppingListArrayList.java file. These methods are already implemented in the ShoppingListArray class.
  2. Ensure all methods in both implementations have appropriate JavaDoc comments.
  3. Generate the JavaDoc html files.
  4. Complete the ShoppingListArrayListTest.java (For many tests, we now just throw a false statement which will cause the test cases to fail. You need to complete them.)

Submit your project to Web-Cat.

Files needed

The files needed to get started are available on Canvas inside of a zipped project called DS_Assignment1_Shopping.zip. Download this, but dont unzip it. Import the project into NetBeans. In your NetBeans, you will get a project called Shopping. When you first import the project, it will run using the array implementation of ShoppingList. After completing the methods described in the first requirement, the project can be run using the ArrayList implementation. Commented code is provided for switching to this version of the simulation in ShoppingSimulation.java.

What you must test

Think of your shopping list as having states. When your program starts and you create the shopping list, it is in its initial state. At this state, the shopping list has nothing in it, so size should be 0. It should also not allow you to remove any element (since it is empty). Once you start adding elements, then the shopping list is not empty anymore and with every element you add, the shopping lists size should reflect one more and you should be able to find the element within it. As you remove elements, the shopping list size should decrease and you will no longer be able to find elements that have been removed.

In the function that you implement, make sure that you can handle special cases. For example, can you double-remove an entry? Can you remove an entry that does not exist in the ArrayList?

A test file for the ArrayList implementation is included in the project. Some method tests are provided, but you must implement the tests that are empty. You can run your tests by right-clicking on either the class or test file in NetBeans and selecting test file.

Code coverage note: Web-cat will run the JUnit tests that you submit and will basically count the percentage of lines of code in your classes that get executed as a result of your test cases. So, you want to try to write test cases that cause all lines of code in all branches of your code, to be executed. (So, if you have an if-else statement, write code in your test case that runs the branch of the if statement when the expression is true, and write other lines of code in your test case that will cause the else clause part of the if statement to be run).

ShoppingSimulation note:

The project contains a class called ShoppingSimulation.java. This simulation class also has the main method that executes when you run the project. You can run the simulation using the ShoppingListArray class or the ShoppingListArrayList class, depending on which line of code you leave uncommented in the main method. It is important for you to understand that this simulation class is there to give you a sense for how the other classes could be used in a real application. When you get everything working, this simulation will run. But just because this simulation runs, this does NOT mean your code is working perfectly. This simulation does not thoroughly test your code at all! You need to write good test cases to make sure your code is working. Also, note that you dont need to write a test file to test this simulation.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

2. Ask several students to explain the directions.

Answered: 1 week ago