Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-17-2007, 06:45 AM
Member
 
Join Date: Nov 2007
Posts: 8
badness is on a distinguished road
Inventory part 3 program problems
Hello all. I wonder if someone would mind taking a look at my code and tell me what I need to do to fix this program that won't compile. It is an inventory program. Thanks a bunch. It is having issues at the end with the last class that I added.

public class Inventory3 {

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 Inventory3


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 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

// Inventory class, used to manage a bunch of Product classes.


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());
return myInventory.getInventoryValue();
}
}

// To store by the year the movie was made

class DVDYr extends Product {

// Year the move was made

private int movieyear;


public DVDYr(int productId, String itemname, int quantity, double itemprice, int year) {


super(productId, itemname, quantity, itemprice);
movieyear = year;
}


public void setYear(int year) {
movieyear = year;
}

// Get the year of this DVD product

public int getYear() {
return movieyear;
}

// add a 5% restocking fee on top

public double getItemValue() {
return super.getItemValue() * 1.05;
}


public double getRestockingFee() {
return super.getItemValue() * .05;
}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-17-2007, 09:00 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
First compile attempt shows we're missing the Product class:
Code:
C:\jexp>javac inventorytest.java inventorytest.java:93: cannot find symbol symbol: class Product class DVDYr extends Product { ^ inventorytest.java:112: cannot find symbol symbol : variable super location: class DVDYr return super.getItemValue() * 1.05; ^ inventorytest.java:116: cannot find symbol symbol : variable super location: class DVDYr return super.getItemValue() * .05; ^ 3 errors
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Final Inventory tweeks badness New To Java 1 01-20-2008 10:18 AM
Inventory Program modification help badness Java Applets 1 01-17-2008 07:24 AM
Inventory part 2 help please badness New To Java 1 12-12-2007 09:51 AM
External Program execution problems vital101 Advanced Java 3 10-30-2007 07:17 PM
Inventory program Nexcompac New To Java 3 07-27-2007 07:51 PM


All times are GMT +3. The time now is 04:31 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org