I am really having trouble in my java class. This is my last class i have to pass before getting my degree in information tech. I truly need some help with my assignments so i can at least pass with a C. After starting the degree i quickly realized information tech was not where i thought i wanted to be, and really have a great admiration for the people who can do it. I would much rather be in buisness management.
Here is my assignment:
Week 5
CheckPoint: Inventory Program Part 1
• Choose a product that lends itself to an inventory (for example, products at your workplace, office supplies, music CDs, DVD movies, or software).
• Create a product class that holds the item number, the name of the product, the number of units in stock, and the price of each unit.
• Create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit). Pay attention to the good programming practices in the text to ensure your source code is readable and well documented.
If you don’t know how to do the Payroll part 3, they have a difficult time with this inventory part 1.
For this inventory part 1, you need to create 2 classes: inventory and inventoryTest (you can give any names you want).
The inventory class contains the item number, the name of the product, the number of units in stock, and the price of each unit. Create the set and get methods. You can also create a method to calculate the value of the inventory.
The inventoryTest instantiates the inventory class to do the display.
So there are 2 classes: inventory that contains the information about the product, and the inventoryTest class that initializes the product class and does the display with its main program.
Please see example below.
For this inventory part 1, you need to create 2 classes: inventory and inventoryTest (you can give any names you want).
The inventory class contains the item number, the name of the product, the number of units in stock, and the price of each unit. Create the set and get methods. You can also create a method to calculate the value of the inventory.
The inventoryTest instantiates the inventory class to do the display.
So there are 2 classes: inventory that contains the information about the product, and the inventoryTest class that initializes the product class and does the display with its main program..
Here is my first attempt at the program:
inventory.java Code:
public class inventory
{
private String dvdName;
public void setDvdName (String name)
{
dvdName = name;
}
public String getDvdName()
{
return dvdName;
}
private String itemNumber;
public void setItemNumber (String number)
{
itemNumber = number;
}
public String getItemNumber()
{
return itemNumber;
}
private String stockNumber;
public void setStockNumber (String stock)
{
stockNumber = stock;
}
public String getStockNumber()
{
return stockNumber;
}
private String price;
public void setPrice (String price)
{
price = price;
}
public String getPrice()
{
return price;
}
private String inventoryValue;
public void setInventoryValue (String value)
{
inventoryValue = value;
}
public String getInventoryValue()
{
return inventoryValue;
}
public void displayMessage()
{
System.out.printf( "DVD Title: %s\n",
getDvdName() );
System.out.printf( "Item #: %s\n",
getItemNumber() );
System.out.printf( "Number in stock: %s\n",
getStockNumber() );
System.out.printf( "Price: $%d\n",
getPrice() );
System.out.printf( "Inventory Value: $%d\n",
getInventoryValue() );
}
} inventorytest.java Code:
import java.util.Scanner;
public class inventorytest
{
public static void main( String args [] )
{
Scanner input = new Scanner( System.in);
inventory myInventory = new inventory("Spiderman","001",11, 19.99);
System.out.println( "Inventory of DVD Movies: " );
System.out.println();
System.out.println();
myInventory.displayMessage();
}
} Here is my second attempt
inventory.java Code:
public class inventory
{
public inventory(String name,
String number,
Int quantity,
Double cost)
{
this.dvdName = name;
this.itemNumber = number;
this.stockNumber = quantity;
this.price = cost;
}
public String getdvdName;
{
return name;
}
public void displayMessage()
{
System.out.printf( "DVD Title: %s\n",vdName);
System.out.printf( "Item #: %s\n",itemNumber);
System.out.printf( "Number in stock: %s\n",
stockNumber);
System.out.printf( "Price: $%d\n",
price);
System.out.printf( "Inventory Value: $%d\n");
}
} I really just dont understand it all, please help me pass this class below is my next assignment
Week 6
CheckPoint: Inventory Program Part 2
• Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.
• Create a method to calculate the value of the entire inventory.
• Create another method to sort the array items by the name of the product.
For this part 2, the new 2 methods are created in the inventory class. They must have a parameter which is an array of the inventory class. In the inventoryTest class, create an array of inventory class. Populate the array. Display the non sorted array. Sort the array by calling the method created in the inventory class. Display the sorted array.
Please see example below.
CheckPoint: Inventory Program Part 3
• Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product you chose (for the DVDs subclass, you could use movie title, for example). In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class. The subclass method should also add a 5% restocking fee to the value of the inventory of that product.
• Modify the output to display this additional feature you have chosen and the restocking fee.
For this part 3, the inventory class remains the same. So do not modify the inventory class. Create a new class for a specific product which is a subclass of the inventory class, e.g. a DVD class that has a new feature (e.g. rating). This is to show inheritance and polymorphism. In the inventoryTest class, the array is now the array of the subclass (e.g. DVD subclass). Display non sorted and sorted arrays.
Please see example below.