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
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
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
Get step-by-step solutions from verified subject matter experts
