Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Jacob Gallucci
- E-mail: [email protected]
- Course: CMPSC 221
- Assignment: Programming Assignment 3 - Store Shopping Cart - Item.java
- Due date: 4/2/2018
- File: pawnShop.java
- Purpose: Driver for Item.java .. Allows user to add items to their cart, remove items from their cart and check out
- Compiler/IDE: OpenJDK 1.8.0_151 (compiled from CLI) - Atom / Vim text editors
- Operating system: Debian Stretch 9
- Reference(s):
- I'lls be honest... this is very similar to every object written for this class .. nothing was referenced.. :)
- */
- public class Item // Item object
- {
- private int itemNum; // private int that holds the item number
- private int itemQuant; // private int that holds the item quantity
- private String itemName; // private string that holds the item name
- private String itemCatagory; // private string that holds the item category
- private double itemPrice; // private double that holds the item price
- public Item() // default constructor, sets everything to 0 or an empty string
- {
- itemNum = 0;
- itemQuant = 0;
- itemName = "";
- itemCatagory = "";
- itemPrice = 0.0;
- }
- public Item(int num, int quant, String name, String catagory, double price) // overloaded constructor sets private vars to passed variables respectively
- {
- itemNum = num;
- itemQuant = quant;
- itemName = name;
- itemCatagory = catagory;
- itemPrice = price;
- }
- public void setNum(int num) // sets item number
- {
- itemNum = num;
- }
- public void setQuantity(int quant) // sets item quantity
- {
- itemQuant = quant;
- }
- public void setName(String name) // sets product name
- {
- itemName = name;
- }
- public void setCatagory(String catagory) // sets item's category
- {
- itemCatagory = catagory;
- }
- public void setPrice(double price) // sets the price of the item
- {
- itemPrice = price;
- }
- public int getNum() // returns item number
- {
- return itemNum;
- }
- public int getQuantity() // returns item quantity
- {
- return itemQuant;
- }
- public String getName() // returns item name
- {
- return itemName;
- }
- public String getCatagory() // returns item quantity
- {
- return itemCatagory;
- }
- public double getPrice() // returns item price
- {
- return itemPrice;
- }
- public String toString() // to string method .. FANCY
- {
- return ("Item Number: " + itemNum + "\nItem Name: " + itemName + "\nCatagory: " + itemCatagory + "\nQuantity: " + itemQuant + "\nPrice: " + itemPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement