############## Inventory.java ###############
/**
* The Class Inventory.
*/
public class Inventory {
/** The product type. */
private String productType;
/** The description. */
private String description;
/** The cost. */
private double cost;
/**
* Instantiates a new inventory.
*
* @param productType the product type
* @param description the description
* @param cost the cost
*/
public Inventory(String productType, String
description, double cost) {
this.productType =
productType;
this.description =
description;
this.cost = cost;
}
/**
* Instantiates a new inventory.
*/
public Inventory() {
// default constructor
}
/**
* Gets the product type.
*
* @return the productType
*/
public String getProductType() {
return productType;
}
/**
* Sets the product type.
*
* @param productType the productType to set
*/
public void setProductType(String productType) {
this.productType =
productType;
}
/**
* Gets the description.
*
* @return the description
*/
public String getDescription() {
return description;
}
/**
* Sets the description.
*
* @param description the description to set
*/
public void setDescription(String description) {
this.description =
description;
}
/**
* Gets the cost.
*
* @return the cost
*/
public double getCost() {
return cost;
}
/**
* Sets the cost.
*
* @param cost the cost to set
*/
public void setCost(double cost) {
this.cost = cost;
}
@Override
public String toString() {
return String.format("Product Type:
%s, Description: %s, Cost: $%.2f", productType, description,
cost);
}
}
################## Test_Inventory.java ##############
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* The Class Test_Inventory.
*/
public class Test_Inventory {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
org.junit.runner.JUnitCore.main("Test_Inventory");
}
/**
* Constructor test 1.
*/
@Test
public void constructorTest1() {
Inventory inventory = new
Inventory("Ring", null, 0);
assertEquals("Ring",
inventory.getProductType());
}
/**
* Constructor test 2.
*/
@Test
public void constructorTest2() {
Inventory inventory = new
Inventory(null, "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 0);
assertEquals("Ring: Diamond Promise
ring in 10K Rose Gold. NOT ring: mood ring",
inventory.getDescription());
}
/**
* Constructor test 3.
*/
@Test
public void constructorTest3() {
Inventory inventory = new
Inventory(null, null, 253.53);
assertEquals("253.53",
String.valueOf(inventory.getCost()));
}
/**
* Setter test 1.
*/
@Test
public void setterTest1() {
Inventory inventory = new
Inventory();
inventory.setProductType("Ring");
assertEquals("Ring",
inventory.getProductType());
}
/**
* Setter test 2.
*/
@Test
public void setterTest2() {
Inventory inventory = new
Inventory();
inventory.setDescription("Ring:
Diamond Promise ring in 10K Rose Gold. NOT ring: mood ring");
assertEquals("Ring: Diamond Promise
ring in 10K Rose Gold. NOT ring: mood ring",
inventory.getDescription());
}
/**
* Setter test 3.
*/
@Test
public void setterTest3() {
Inventory inventory = new
Inventory();
inventory.setCost(253.53);
assertEquals("253.53",
String.valueOf(inventory.getCost()));
}
/**
* To string test.
*/
@Test
public void toStringTest() {
Inventory inventory = new
Inventory("Ring", "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 253.53);
String m =
inventory.toString();
assertEquals("Product Type: Ring,
Description: Ring: Diamond Promise ring in 10K Rose Gold. NOT ring:
mood ring, Cost: $253.53", m);
}
}
################# JewelleryStore.java ##############
/**
* The Class JewelleryStore.
*/
public class JewelleryStore {
/** The store name. */
private String storeName;
/** The inventory sold. */
private Inventory[] inventorySold;
/** The items sold. */
private int itemsSold;
/**
* Instantiates a new jewellery store.
*/
public JewelleryStore() {
this.inventorySold = new
Inventory[10];
this.itemsSold = 0;
}
/**
* Instantiates a new jewellery store.
*
* @param storeName the store name
*/
public JewelleryStore(String storeName) {
this.inventorySold = new
Inventory[10];
this.storeName = storeName;
this.itemsSold = 0;
}
/**
* Gets the store name.
*
* @return the storeName
*/
public String getStoreName() {
return storeName;
}
/**
* Sets the store name.
*
* @param storeName the storeName to set
*/
public void setStoreName(String storeName) {
this.storeName = storeName;
}
/**
* Gets the inventory sold.
*
* @return the inventorySold
*/
public Inventory[] getInventorySold() {
return inventorySold;
}
/**
* Sets the inventory sold.
*
* @param inventorySold the inventorySold to set
*/
public void setInventorySold(Inventory[]
inventorySold) {
this.inventorySold =
inventorySold;
}
/**
* Gets the items sold.
*
* @return the itemsSold
*/
public int getItemsSold() {
return itemsSold;
}
/**
* Sets the items sold.
*
* @param itemsSold the itemsSold to set
*/
public void setItemsSold(int itemsSold) {
this.itemsSold = itemsSold;
}
/**
* Adds the.
*
* @param inventory the inventory
*/
public void add(Inventory inventory) {
this.inventorySold[itemsSold++] =
inventory;
}
@Override
public String toString() {
return String.format("StoreName:
%s, ItemsSold: %d", storeName, itemsSold);
}
}
################# Test_JewelleryStore.java ################
import static org.junit.Assert.assertEquals;
import org.junit.Test;
/**
* The Class Test_JewelleryStore.
*/
public class Test_JewelleryStore {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
org.junit.runner.JUnitCore.main("Test_JewelleryStore");
}
/**
* Constructor test 1.
*/
@Test
public void constructorTest1() {
JewelleryStore jewelleryStore = new
JewelleryStore("BB Jewellers");
assertEquals("BB Jewellers",
jewelleryStore.getStoreName());
}
/**
* Setter test 1.
*/
@Test
public void setterTest1() {
JewelleryStore jewelleryStore = new
JewelleryStore();
jewelleryStore.setStoreName("BB
Jewellers");
assertEquals("BB Jewellers",
jewelleryStore.getStoreName());
}
/**
* Setter test 2.
*/
@Test
public void setterTest2() {
JewelleryStore jewelleryStore = new
JewelleryStore();
Inventory[] inventory = {new
Inventory("Ring", "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 253.53)};
jewelleryStore.setInventorySold(inventory);
assertEquals("Ring",
jewelleryStore.getInventorySold()[0].getProductType());
}
/**
* Setter test 3.
*/
@Test
public void setterTest3() {
JewelleryStore jewelleryStore = new
JewelleryStore();
jewelleryStore.setItemsSold(2);
assertEquals("2",
String.valueOf(jewelleryStore.getItemsSold()));
}
/**
* Adds the test.
*/
@Test
public void addTest() {
JewelleryStore jewelleryStore = new
JewelleryStore();
Inventory inventory = new
Inventory("Ring", "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 253.53);
jewelleryStore.add(inventory);
assertEquals("1",
String.valueOf(jewelleryStore.getItemsSold()));
}
/**
* To string test.
*/
@Test
public void toStringTest() {
JewelleryStore jewelleryStore = new
JewelleryStore("BB Jewellers");
Inventory inventory = new
Inventory("Ring", "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 253.53);
jewelleryStore.add(inventory);
String m =
jewelleryStore.toString();
assertEquals("StoreName: BB
Jewellers, ItemsSold: 1", m);
}
}
################# P1Driver.java ###################
/**
* The Class P1Driver.
*/
public class P1Driver {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
JewelleryStore jewelleryStore = new
JewelleryStore("BB Jewellers");
Inventory inventory1 = new
Inventory("Ring", "Ring: Diamond Promise ring in 10K Rose Gold. NOT
ring: mood ring", 253.53);
Inventory inventory2 = new
Inventory("Necklace", "Necklace: Pure Diamond", 1000.23);
Inventory inventory3 = new
Inventory("Braclet", "Braclet: Made of borzen and allow",
36.20);
Inventory inventory4 = new
Inventory("Anklet", "Anklet: Silver coated", 13.00);
Inventory inventory5 = new
Inventory("Bangal", "Bangal:23 cart pure gold", 40.88);
Inventory inventory6 = new
Inventory("Chain", "Chain: 23 cart pure gold", 743.13);
jewelleryStore.add(inventory1);
jewelleryStore.add(inventory2);
jewelleryStore.add(inventory3);
jewelleryStore.add(inventory4);
jewelleryStore.add(inventory5);
jewelleryStore.add(inventory6);
System.out.println("Welome to "
+ jewelleryStore.getStoreName());
System.out.println(jewelleryStore.getStoreName());
for (Inventory inventory :
jewelleryStore.getInventorySold()) {
if (inventory !=
null) {
System.out.println(inventory.toString());
}
}
System.out.println("Thank you
message");
}
}
If your program does not compile, you will not receive any points! You will write a program to keep up with a Jewelry...
Here is a sample run of the tester program: Make sure your program follows the Java Coding Guidelines. Consider the following class: /** * A store superclass with a Name and Sales Tax Rate */ public class Store { public final double SALES_TAX_RATE = 0.06; private String name; /** * Constructor to create a new store * @param newName */ public Store(String newName) { name = newName; } ...
Order up:: Write a program that will be used to keep track of orders placed at a donut shop. There are two types of items that can be ordered: coffee or donuts. Your program will have a class for each order type, and an abstract superclass. Coffee orders are constructed with the following information: quantity (int) - how many coffees are being ordered size (String) - the size of the coffees (all coffees in the order have the same size)...
Need this program in C#. Thank you 3/19 Lab11 PartC Dur Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named Retailltem and should hold data about an item in a retail store. The class will have the following member variables. Description- string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the...
In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...
Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...
When answering this question, can you please specify what you name your files? Thank you! Write a Java application, and an additional class to represent some real-world entity. Keep in mind that a class is a model in code of something real or imagined, which has attributes (member variables) and behaviors (member methods). The class will: a. Create a total of 5 member variables for the class, selecting the appropriate data types for each field. For example, a class to...
M01 PA C++ Classes and Objects INTRODUCTION: Write a C++ program that implements and utilizes a Stereo Receiver Class/Object. INCLUDE IN YOUR ASSIGNMENT At the top of each of your C++ programs, you should have at least four lines of documentation: Program name (the C++ file name(s)), Author (your name), Date last updated, and Purpose (a brief description of what the program accomplishes). Here is an example: // Program name: tictactoe.cpp // Author: Rainbow Dash // Date last updated: 5/26/2016...
C++ Simple code please Thank you in advance B. Write a C++ program as per the following specifications: a. Define the class BankAccount to store a bank customer's account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank...
Write a program to subtract large unsigned integers. Your program should prompt and read in two large unsigned integers. The two large integers should be stored arrays, one array for each integer. The integers should be stored with one digit per location in the two arrays. The first integer should be no smaller than the second. Your program should subtract the second integer from the first. The result should be stored in an array, again one digit per location in...
Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named RetailItem and should hold data about an item in a retail store. The class will have the following member variables. Description - string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the item...