Question: Test task (JUnit Test) using assert Task 1: As a developer, I want to test that I cannot add a showing to the cart if

Test task (JUnit Test) using assert

Task 1: As a developer, I want to test that I cannot add a showing to the cart if it's sold out, so I know the code works.

Task 2: As a developer, I want to test that if there is one seat left for a showing, that I can't put 2 of those showings in a cart, so I know the code works

Cart.java

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model;

import java.util.List; import java.util.ArrayList;

/** * * @author Francheska */ public class Cart{ // Item Number private int _itemNumber; // The items private List _itemsFood = new ArrayList(); private List _itemsFoodSize = new ArrayList(); private List _itemsShowing = new ArrayList(); private ArrayList _getpayment = new ArrayList(); // Item Number constructor public Cart(int itemNumber){ this._itemNumber = itemNumber; }

Cart() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } // Get Item Number public int getItemNumber(){ return _itemNumber; } // Get Iteams public List getItemsFood(){ return _itemsFood; } public List getItemsFoodSize(){ return _itemsFoodSize; } public List getItemsShowing(){ return _itemsShowing; } // Set Item Number public int setItemNumber(){ return _itemNumber; } // Set Items public void addItems(Food item, Food.FoodSize size){ this._itemsFood.add(item); this._itemsFoodSize.add(size); } public void addShowing(Showing showing, int count){ this._itemsShowing.add(showing); _itemNumber = _itemNumber + count; } // remove public void removeitem(Showing showing, int count, Food item){ this._itemsShowing.remove(showing); _itemNumber = _itemNumber - count; this._itemsFood.remove(item); } }

CartHelper.java

/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package model;

import model.Food; import model.Cart; import model.FoodHelper; import model.IDataStorage;

/** * * @author Francheska */ public class CartHelper { private static FakeDataStorage _storeCart = new FakeDataStorage(); private int count = 0; private Cart cart = new Cart(count); public void CartAddFood(Food food, Food.FoodSize size){ cart.addItems(food, size); count ++; } private void CartAddShowing(Showing showing, int count){ cart.addShowing(showing, count); } private void CartRemove(Showing showing, int count, Food item){ cart.removeitem(showing, count, item); } private void checkout(Cart cart, Payment payment){ System.out.println("Total food you are purchasing:" + cart.getItemsFood()); System.out.println("The movie you are purchasing:" + cart.getItemsShowing()); System.out.println("Which payment method are you using?" + payment.getPaymentType()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!