- public class Inventorypart2 {
-
-
public static void main(String args []) {
-
-
DVD dvd;
-
-
-
dvd = new DVD(1, "The Fellowship of the Ring", 5, 14.95);
-
System.out.println(dvd);
-
-
dvd = new DVD(2, "The Chamber", 7, 12.99);
-
System.out.println(dvd);
-
-
dvd = new DVD(3, "Superman 3", 6, 19.99);
-
System.out.println(dvd);
-
-
dvd = new DVD(4, "Van Helsing", 3, 10.99);
-
System.out.println(dvd);
-
-
} //end main
-
-
} // end class Inventorypart2
-
-
-
class DVD {
-
private int dvdItem;
-
private String dvdTitle;
-
private int dvdStock;
-
private double dvdPrice;
-
-
public DVD(int item, String title, int stock, double price) {
-
dvdItem = item;
-
dvdTitle = title;
-
dvdStock = stock;
-
dvdPrice = price;
-
} //end four-argument constructor
-
-
// set DVD Item
-
public void setDvdItem(int item) {
-
dvdItem = item;
-
} //end method set Dvd Item
-
-
//return DVD Item
-
public int getDvdItem() {
-
return dvdItem;
-
} //end method get Dvd Item
-
-
//set DVD Title
-
public void setDvdTitle(String title) {
-
dvdTitle = title;
-
} //end method set Dvd Title
-
-
//return Dvd Title
-
public String getDvdTitle() {
-
return dvdTitle;
-
} //end method get Dvd Title
-
-
public void setDvdStock(int stock) {
-
dvdStock = stock;
-
} //end method set Dvd Stock
-
-
//return dvd Stock
-
public int getDvdStock() {
-
return dvdStock;
-
} //end method get Dvd Stock
-
-
public void setDvdPrice(double price) {
-
dvdPrice = price;
-
} //end method setdvdPrice
-
-
//return DVD Price
-
public double getDvdPrice() {
-
return dvdPrice;
-
} //end method get Dvd Price
-
-
//calculate inventory value
-
public double value() {
-
return dvdPrice * dvdStock;
-
} //end method value
-
-
public String toString() {
-
-
return String.format("item=%3d title=%-20s units=%d price=%.2f value=%.2f",
-
dvdItem, dvdTitle, dvdStock, dvdPrice, value());
-
}
-
-
} //end class DVD
-
-
class Inventory {
-
DVD movies[] = new DVD[100];
-
-
// Add to inventory
-
public void addToInventory(DVD movie) {
-
-
-
}
-
-
// Get inventory value
-
public double getInventoryValue() {
-
-
-
Inventory myInventory = new Inventory();
-
-
-
myInventory.addToInventory(new DVD(1, "Remember the Titans", 5, 14.95));
-
-
// Print out the inventory total value
-
System.out.println("Total value of inventory is: " + myInventory.getInventoryValue());
-
-
}
-
}
-
I figured I would ask this again since noone helped me the first time...I cannot figure out how to put in the bracket without it saying reached end of file without parsing..Am I missing something?
0 1413 Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Bailo |
last post by:
The c# *return* statement has been bothering me the past few months.
I don't like the fact that you can have different code paths in a method
and have multiple return statements. To me, it...
|
by: Nan Li |
last post by:
Hello, all,
Does C/C++ ever check the return statement for a non-void function?
Look at my simple code below
int foo()
{
}
int main()
|
by: sammyboy78 |
last post by:
I'm trying to create a class "WeeklyPay" that contains the methods that class "WeeklyPayTest" will use to compute the weekly pay of an employee when the user inputs employee name, hours worked, and...
|
by: KoreyAusTex |
last post by:
If anyone can help me figure out the what the missing return statements are, I think it might be the fact that I need to add a return false in the getValue()?
import java.util.*;
public class...
|
by: Annie Soomro |
last post by:
Getting "missing return statement" error for following code:
import java.sql.*;
public class DatabaseManager{
public static int add(String user,String password)throws Exception{
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |