Inventory part 6

Reply

Join Date: Sep 2007
Posts: 3
Reputation: cmymazda is an unknown quantity at this point 
Solved Threads: 0
cmymazda cmymazda is offline Offline
Newbie Poster

Inventory part 6

 
0
  #1
Oct 7th, 2007
Hello,

I am trying to figure out how to correct my errors. I am new at this and this is due today. The actual assignment is ....
Modify the Inventory Program to include an Add button, a Delete button, and a Modify
button on the GUI. These buttons should allow the user to perform the corresponding
actions on the item name, the number of units in stock, and the price of each unit. An
item added to the inventory should have an item number one more than the previous last
item.
• Add a Save button to the GUI that saves the inventory to a C:\data\inventory.dat file.
• Use exception handling to create the directory and file if necessary.
• Add a search button to the GUI that allows the user to search for an item in the inventory
by the product name. If the product is not found, the GUI should display an appropriate
message. If the product is found, the GUI should display that product’s information in the
GUI.


Here are my errors
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
^
C:\IT315\Inventory6\Inventory6.java:42: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI



Here is my code

  1.  
  2. import java.util.*; // using java libraries
  3.  
  4. public class Inventory6 {
  5.  
  6. public static void main(String[] args) {
  7.  
  8. FeatDVD dvd;
  9. Inventory inventory = new Inventory();
  10.  
  11. dvd = new FeatDVD(0, "Bad Boys", 5, 12.99, "Comedy");
  12. inventory.add(dvd);
  13.  
  14. dvd = new FeatDVD(1, "Color Purple", 7, 14.99, "Drama");
  15. inventory.add(dvd);
  16.  
  17. dvd = new FeatDVD(2, "Madea Family Reunion", 6, 13.99, "Drama");
  18. inventory.add(dvd);
  19.  
  20. dvd = new FeatDVD(3, "Diary of a Mad Black Woman", 3, 15.99, "Drama");
  21. inventory.add(dvd);
  22.  
  23. dvd = new FeatDVD(4, "Forest Gump", 8, 11.99, "Comedy");
  24. inventory.add(dvd);
  25.  
  26. dvd = new FeatDVD(5, "How Stella Got Her Groove Back", 2, 12.99, "Drama");
  27. inventory.add(dvd);
  28.  
  29. dvd = new FeatDVD(6, "What's love Got to do With it", 7, 15.99, "Drama");
  30. inventory.add(dvd);
  31.  
  32. dvd = new FeatDVD(7, "Purple Rain", 7, 11.99, "Drama");
  33. inventory.add(dvd);
  34.  
  35. inventory.display();
  36. GUI gui = new GUI(inventory); // Start the GUI
  37.  
  38. OutputDVD output = new OutputDVD(inventory);
  39.  
  40. } // end main
  41.  
  42. } // end class Inventory6
  43.  
  44.  
  45.  
  46. /**** Class decribes DVD while demostrating polymorphism and inheritance**/
  47.  
  48. class DVD implements Comparable
  49. {
  50. private int dvditem;
  51. private String dvdtitle;
  52. private int dvdstock;
  53. private double dvdprice;
  54.  
  55. // Constructor
  56. DVD()
  57. {
  58. dvditem = 0;
  59. dvdtitle = "";
  60. dvdstock = 0;
  61. dvdprice = 0;
  62. }// end constructor
  63.  
  64. //constructor initializes variables
  65. DVD(int item, String title, int stock, double price)
  66. {
  67. this.dvditem = item;
  68. this.dvdtitle = title;
  69. this.dvdstock = stock;
  70. this.dvdprice = price;
  71. }
  72.  
  73. private void setTitle( String title )
  74. {
  75. this.dvdtitle = title;
  76. }
  77.  
  78. public String getdvdTitle()
  79. {
  80. return dvdtitle;
  81. }
  82.  
  83. private void setdvdItem( int item )
  84. {
  85. this.dvditem = item;
  86. }
  87.  
  88. public int getdvdItem()
  89. {
  90. return dvditem;
  91. }
  92.  
  93. private void setdvdStock( int stock )
  94. {
  95. this.dvdstock = stock;
  96. }
  97.  
  98. public int getdvdStock()
  99. {
  100. return dvdstock;
  101. }
  102.  
  103. private void setdvdPrice (double price )
  104. {
  105. this.dvdprice = price;
  106. }
  107.  
  108. public double getdvdPrice()
  109. {
  110. return dvdprice;
  111. }
  112.  
  113. public double getValue()
  114. {
  115. double value = dvdstock * dvdprice;
  116. return value;
  117. }
  118.  
  119. // This method tells the sort method what is to be sorted
  120. public int compareTo(Object o)
  121. {
  122. return dvdtitle.compareTo(((DVD) o).getdvdTitle());
  123. }
  124.  
  125. // This method passes the format for the string
  126. public String toString()
  127. {
  128. return String.format("Unit number:%d %12s Units:%2d Price: $%5.2f Movie value: $%6.2f",
  129. dvditem, dvdtitle, dvdstock, dvdprice, getValue());
  130. }
  131. } // end class DVD
  132.  
  133.  
  134. /**** This is a subclass that adds 5% restocking fee and new feature genres***/
  135.  
  136. class FeatDVD extends DVD
  137. {
  138. private String genres;
  139.  
  140. // class constructor
  141. FeatDVD(int item, String title, int stock, double price, String genres)
  142. {
  143. super(item, title, stock, price);
  144. this.genres = genres;
  145. }
  146. public String getGenres()
  147. {
  148. return genres;
  149. }
  150.  
  151. public double getValue()
  152. {// getvalue method overrides
  153. // getvalue method in the superclass
  154. double value = 1.05F * super.getValue();
  155. return value;
  156. }// end getValue method
  157.  
  158. public String toString()
  159. {//toString method overrides the superclass toString method
  160. //adding another fields
  161. return super.toString() + "Genre:" + genres;
  162. }// end toString method
  163.  
  164. } // end class FeatDVD
  165.  
  166.  
  167. /*****class has inventory of DVDs.
  168. * This class has methods to add and display dvds****/
  169.  
  170. class Inventory
  171. {
  172. private DVD[] dvds;
  173. private int nCount;
  174.  
  175. // constructor
  176. Inventory()
  177. {
  178. dvds = new DVD[8];
  179. nCount = 0;
  180. }
  181.  
  182.  
  183. public int getNcount()
  184. {
  185. return nCount;
  186. }
  187.  
  188. // method adds DVD to inventory
  189. public void add(DVD dvd)
  190. {
  191. dvds[nCount] = dvd;
  192. ++nCount;
  193. sort();
  194. }
  195.  
  196. public void delete(int n)
  197. {
  198. if (nCount > 0)
  199. {
  200. dvds[n] = dvds[nCount-1];
  201. --nCount;
  202. sort();
  203. }
  204. }
  205. public int search(String seek)
  206. {
  207.  
  208. int n = -1
  209. for (int i = 0; i < nCount; i++) {
  210. if (seek.equalsIgnoreCase(dvds[i].getdvdTitle())) {
  211. n = i;
  212. break;
  213.  
  214. }
  215. }
  216. return n;
  217. }
  218.  
  219. public FeatDVD getFeatDVD(int n)
  220. {
  221. return (FeatDVD) dvds[n];
  222. }
  223. // method calculates total value of inventory
  224. public double getTotalValue()
  225. {
  226.  
  227. double totalValue = 0;
  228. for (int i = 0; i < nCount; i++)
  229. totalValue = dvds[i].getValue();
  230. return totalValue;
  231. } // end getTotalValue
  232.  
  233. public DVD getDVD(int n) //use in GUI
  234. {// protects n and keep in range
  235. if (n<0)
  236. n = 0;
  237. else if (n >= nCount)
  238. n = nCount - 1;
  239. return (n >= 0) ? dvds[n] : null;
  240. }
  241.  
  242.  
  243. // sorts the DVDs
  244. private void sort()
  245. {
  246.  
  247. if (nCount > 0)
  248. Arrays.sort(dvds, 0, nCount);
  249. }// end sort method
  250.  
  251. public void display()
  252. {
  253. for (int i = 0; i < nCount; i++)
  254. System.out.printf("%2d: %s\n", i, getFeatDVD(i));
  255. }
  256.  
  257.  
  258. } // end class Inventory
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,191
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 485
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Inventory part 6

 
0
  #2
Oct 8th, 2007
  1. GUI gui = new GUI(inventory); // Start the GUI
You calling class GUI (GUI.java) that I do not see you implement it. Either you re-used your code from previous assignment and you forgot to copy and paste in new project or you actually forgot to code this class
Last edited by peter_budo; Oct 8th, 2007 at 12:09 pm.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC