Advertisement
SageTheWizard

Item.java

Apr 1st, 2018
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.53 KB | None | 0 0
  1. /*
  2.   Author: Jacob Gallucci
  3.   Course: CMPSC 221
  4.   Assignment: Programming Assignment 3 - Store Shopping Cart  - Item.java
  5.   Due date: 4/2/2018
  6.   File: pawnShop.java
  7.   Purpose: Driver for Item.java .. Allows user to add items to their cart, remove items from their cart and check out
  8.   Compiler/IDE: OpenJDK 1.8.0_151 (compiled from CLI) - Atom / Vim text editors
  9.   Operating system: Debian Stretch 9
  10.   Reference(s):
  11.                   I'lls be honest... this is very similar to every object written for this class .. nothing was referenced.. :)
  12. */
  13. public class Item // Item object
  14. {
  15.   private int itemNum; // private int that holds the item number
  16.   private int itemQuant; // private int that holds the item quantity
  17.   private String itemName; // private string that holds the item name
  18.   private String itemCatagory; // private string that holds the item category
  19.   private double itemPrice;       // private double that holds the item price
  20.  
  21.   public Item() // default constructor, sets everything to 0 or an empty string
  22.   {
  23.     itemNum = 0;
  24.     itemQuant = 0;
  25.     itemName = "";
  26.     itemCatagory = "";
  27.     itemPrice = 0.0;
  28.   }
  29.   public Item(int num, int quant, String name, String catagory, double price) // overloaded constructor sets private vars to passed variables respectively
  30.   {
  31.     itemNum = num;
  32.     itemQuant = quant;
  33.     itemName = name;
  34.     itemCatagory = catagory;
  35.     itemPrice = price;
  36.   }
  37.   public void setNum(int num) // sets item number
  38.   {
  39.     itemNum = num;
  40.   }
  41.   public void setQuantity(int quant) // sets item quantity
  42.   {
  43.     itemQuant = quant;
  44.   }
  45.   public void setName(String name) // sets product name
  46.   {
  47.     itemName = name;
  48.   }
  49.   public void setCatagory(String catagory) // sets item's category
  50.   {
  51.     itemCatagory = catagory;
  52.   }
  53.   public void setPrice(double price) // sets the price of the item
  54.   {
  55.     itemPrice = price;
  56.   }
  57.   public int getNum() // returns item number
  58.   {
  59.     return itemNum;
  60.   }
  61.   public int getQuantity() // returns item quantity
  62.   {
  63.     return itemQuant;
  64.   }
  65.   public String getName() // returns item name
  66.   {
  67.     return itemName;
  68.   }
  69.   public String getCatagory() // returns item quantity
  70.   {
  71.     return itemCatagory;
  72.   }
  73.   public double getPrice() // returns item price
  74.   {
  75.     return itemPrice;
  76.   }
  77.   public String toString() // to string method .. FANCY
  78.   {
  79.     return ("Item Number: " + itemNum + "\nItem Name: " + itemName + "\nCatagory: " + itemCatagory + "\nQuantity: " + itemQuant + "\nPrice: " + itemPrice);
  80.   }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement