473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Misplaced bracket error in code

I cannot figure out why my main is not identifying my classes, is there a bracket misplaced or something? Here are the errors I am getting

Expand|Select|Wrap|Line Numbers
  1. C:\Documents and Settings\Regina Denson\My Documents\JCreator LE\MyProjects\Inventory6.java:37: cannot find symbol
  2. symbol  : class GUI
  3. location: class Inventory6
  4.         GUI gui = new GUI(inventory); // Start the GUI
  5.         ^
  6. C:\Documents and Settings\Regina Denson\My Documents\JCreator LE\MyProjects\Inventory6.java:37: cannot find symbol
  7. symbol  : class GUI
  8. location: class Inventory6
  9.         GUI gui = new GUI(inventory); // Start the GUI
  10.                       ^
  11. C:\Documents and Settings\Regina Denson\My Documents\JCreator LE\MyProjects\Inventory6.java:39: cannot find symbol
  12. symbol  : class OutputDVD
  13. location: class Inventory6
  14.         OutputDVD output = new OutputDVD(inventory);
  15.         ^
  16. C:\Documents and Settings\Regina Denson\My Documents\JCreator LE\MyProjects\Inventory6.java:39: cannot find symbol
  17. symbol  : class OutputDVD
  18. location: class Inventory6
  19.         OutputDVD output = new OutputDVD(inventory);
  20.                                ^
And Here is my code

Expand|Select|Wrap|Line Numbers
  1. import java.util.*; // using java libraries
  2.  
  3. public class Inventory6 {
  4.  
  5.     public static void main(String[] args) 
  6.         {
  7.  
  8.         FeatDVD dvd;
  9.         Inventory inventory = new Inventory();
  10.  
  11.         dvd = new FeatDVD(0, "Hitch", 5, 12.99, "Columbia Pictures");
  12.         inventory.add(dvd);
  13.  
  14.         dvd = new FeatDVD(1, "Unleashed", 7, 14.99, "Universal Studios");
  15.         inventory.add(dvd);
  16.  
  17.         dvd = new FeatDVD(2, "Batman Forever", 6, 13.99, "Warner Bros");
  18.         inventory.add(dvd);
  19.  
  20.         dvd = new FeatDVD(3, "Taxi", 3, 15.99, "20TH Century Fox");
  21.         inventory.add(dvd);
  22.  
  23.         dvd = new FeatDVD(4, "Free Willy", 8, 11.99, "Warner Bros");
  24.         inventory.add(dvd);
  25.  
  26.         dvd = new FeatDVD(5, "Cliffhanger", 2, 12.99, "Columbia Tristar");
  27.         inventory.add(dvd);        
  28.  
  29.         dvd = new FeatDVD(6, "A Christmas Story", 7, 15.99, "Warner Bros");
  30.         inventory.add(dvd);
  31.  
  32.         dvd = new FeatDVD(7, "Stir of Echos", 7, 11.99, "Artisan");
  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
  259.  
  260. Please HELP
Nov 30 '07 #1
9 1830
Hi, Gina!

I do not see where you declare the class GUI. If it is in a different package, you will need to import it before using it.

import packagename.GUI;

kind of like you're importing the java.util package contents.
Nov 30 '07 #2
samido
52
dude, make sure the class GUI is compiled successfully, this is why you getting this problem, chaww...
Nov 30 '07 #3
Hi, Gina!

I do not see where you declare the class GUI. If it is in a different package, you will need to import it before using it.

import packagename.GUI;

kind of like you're importing the java.util package contents.

Thanks so much!! So I add that import line under the first import line?
Nov 30 '07 #4
Hi, Gina!

I do not see where you declare the class GUI. If it is in a different package, you will need to import it before using it.

import packagename.GUI;

kind of like you're importing the java.util package contents.
Well now I get these errors
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:3: package packagename does not exist
import packagename.GUI;
^
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:38: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
^
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:38: cannot find symbol
symbol : class GUI
location: class Inventory6
GUI gui = new GUI(inventory); // Start the GUI
^
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:40: cannot find symbol
symbol : class OutputDVD
location: class Inventory6
OutputDVD output = new OutputDVD(inventory);
^
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:40: cannot find symbol
symbol : class OutputDVD
location: class Inventory6
OutputDVD output = new OutputDVD(inventory);
^

HMMMMM brain pain
Nov 30 '07 #5
dude, make sure the class GUI is compiled successfully, this is why you getting this problem, chaww...
I am still learning and I don't know how but thanks so much for your reply!!
Nov 30 '07 #6
Hi, Gina!

I do not see where you declare the class GUI. If it is in a different package, you will need to import it before using it.

import packagename.GUI;

kind of like you're importing the java.util package contents.
So I tried it a little different and I only get one error
C:\Program Files\Java\jdk1.6.0_03\bin\Inventory6.java:38: cannot find symbol
symbol : constructor Inventory(Inventory)
location: class Inventory
Inventory output = new Inventory(inventory);
^

Here is te code

import java.util.*; // using java libraries


public class Inventory6 {

public static void main(String[] args)
{

FeatDVD dvd;
Inventory inventory = new Inventory();

dvd = new FeatDVD(0, "Bad Boys", 5, 12.99, "Comedy");
inventory.add(dvd);

dvd = new FeatDVD(1, "Color Purple", 7, 14.99, "Drama");
inventory.add(dvd);

dvd = new FeatDVD(2, "Madea Family Reunion", 6, 13.99, "Drama");
inventory.add(dvd);

dvd = new FeatDVD(3, "Diary of a Mad Black Woman", 3, 15.99, "Drama");
inventory.add(dvd);

dvd = new FeatDVD(4, "Forest Gump", 8, 11.99, "Comedy");
inventory.add(dvd);

dvd = new FeatDVD(5, "How Stella Got Her Groove Back", 2, 12.99, "Drama");
inventory.add(dvd);

dvd = new FeatDVD(6, "What's love Got to do With it", 7, 15.99, "Drama");
inventory.add(dvd);

dvd = new FeatDVD(7, "Purple Rain", 7, 11.99, "Drama");
inventory.add(dvd);


Inventory output = new Inventory(inventory);

} // end main

} // end class Inventory6



/**** Class decribes DVD while demostrating polymorphism and inheritance**/

class DVD implements Comparable
{
private int dvditem;
private String dvdtitle;
private int dvdstock;
private double dvdprice;

// Constructor
DVD()
{
dvditem = 0;
dvdtitle = "";
dvdstock = 0;
dvdprice = 0;
}// end constructor

//constructor initializes variables
DVD(int item, String title, int stock, double price)
{
this.dvditem = item;
this.dvdtitle = title;
this.dvdstock = stock;
this.dvdprice = price;
}

private void setTitle( String title )
{
this.dvdtitle = title;
}

public String getdvdTitle()
{
return dvdtitle;
}

private void setdvdItem( int item )
{
this.dvditem = item;
}

public int getdvdItem()
{
return dvditem;
}

private void setdvdStock( int stock )
{
this.dvdstock = stock;
}

public int getdvdStock()
{
return dvdstock;
}

private void setdvdPrice (double price )
{
this.dvdprice = price;
}

public double getdvdPrice()
{
return dvdprice;
}

public double getValue()
{
double value = dvdstock * dvdprice;
return value;
}

// This method tells the sort method what is to be sorted
public int compareTo(Object o)
{
return dvdtitle.compareTo(((DVD) o).getdvdTitle());
}

// This method passes the format for the string
public String toString()
{
return String.format("Unit number:%d %12s Units:%2d Price: $%5.2f Movie value: $%6.2f",
dvditem, dvdtitle, dvdstock, dvdprice, getValue());
}
} // end class DVD


/**** This is a subclass that adds 5% restocking fee and new feature genres***/

class FeatDVD extends DVD
{
private String genres;

// class constructor
FeatDVD(int item, String title, int stock, double price, String genres)
{
super(item, title, stock, price);
this.genres = genres;
}
public String getGenres()
{
return genres;
}

public double getValue()
{// getvalue method overrides
// getvalue method in the superclass
double value = 1.05F * super.getValue();
return value;
}// end getValue method

public String toString()
{//toString method overrides the superclass toString method
//adding another fields
return super.toString() + "Genre:" + genres;
}// end toString method

} // end class FeatDVD


/*****class has inventory of DVDs.
* This class has methods to add and display dvds****/

class Inventory
{
private DVD[] dvds;
private int nCount;

// constructor
Inventory()
{
dvds = new DVD[8];
nCount = 0;
}


public int getNcount()
{
return nCount;
}

// method adds DVD to inventory
public void add(DVD dvd)
{
dvds[nCount] = dvd;
++nCount;
sort();
}

public void delete(int n)
{
if (nCount > 0)
{
dvds[n] = dvds[nCount-1];
--nCount;
sort();
}
}
public int search(String seek)
{

int n = -1;
for (int i = 0; i < nCount; i++) {
if (seek.equalsIgnoreCase(dvds[i].getdvdTitle())) {
n = i;
break;

}
}
return n;
}

public FeatDVD getFeatDVD(int n)
{
return (FeatDVD) dvds[n];
}
// method calculates total value of inventory
public double getTotalValue()
{

double totalValue = 0;
for (int i = 0; i < nCount; i++)
totalValue = dvds[i].getValue();
return totalValue;
} // end getTotalValue

public DVD getDVD(int n) //use in GUI
{// protects n and keep in range
if (n<0)
n = 0;
else if (n >= nCount)
n = nCount - 1;
return (n >= 0) ? dvds[n] : null;
}


// sorts the DVDs
private void sort()
{

if (nCount > 0)
Arrays.sort(dvds, 0, nCount);
}// end sort method

public void display()
{
for (int i = 0; i < nCount; i++)
System.out.printf("%2d: %s\n", i, getFeatDVD(i));
}


} // end class Inventory
Nov 30 '07 #7
Laharl
849 Expert 512MB
The compiler is complaining because you have no constructor written for the Inventory class that takes an Inventory parameter, which I would assume is a copy constructor, which would assign the member values of the input Inventory to the newly constructed Inventory object.

Eg:
Expand|Select|Wrap|Line Numbers
  1. public class Foo {
  2.  private int a;
  3.  public Foo(Foo other){//Takes a parameter of a Foo object
  4.   a = other.a; //Assigns a to the input object's a value
  5.  }
  6.   ...
  7. }
  8.  
Nov 30 '07 #8
The compiler is complaining because you have no constructor written for the Inventory class that takes an Inventory parameter, which I would assume is a copy constructor, which would assign the member values of the input Inventory to the newly constructed Inventory object.

Eg:
Expand|Select|Wrap|Line Numbers
  1. public class Foo {
  2.  private int a;
  3.  public Foo(Foo other){//Takes a parameter of a Foo object
  4.   a = other.a; //Assigns a to the input object's a value
  5.  }
  6.   ...
  7. }
  8.  
I am so new at this I guess I just don't understand the whole "Foo" thing. But thank you so much for your reply
Nov 30 '07 #9
Laharl
849 Expert 512MB
The Foo class was an example to give you an idea of what this needs to look like. The type of constructor I mentioned is called a "copy constructor" because it makes the new object a copy of the old one.
Dec 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ken in Melbourne Australia | last post by:
If I use the curly bracket syntax (referred to as the complex syntax) within a string, how do I get to call a function within it? The php manual says that the first (or previous) character for...
3
by: Robert Mark Bram | last post by:
Howdy All! Is there any difference between referencing objects and attributes with dot notation or bracket notation? Example, document.formname.controlname document Can I access...
8
by: Jimmy Smits | last post by:
Hi I have been playing with some JS that I cut from another page. It is a NCAA tournament bracket. When the user clicks on the submit button it sends the predictions to a db I have created. I got...
102
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler...
3
by: dink | last post by:
helo, I'm new to VS 7.1, searched thru help but no luck. Anyone can tell me a keyboard shortcut to go to the ending bracket when cursor is under opening bracket and vice-versa. I think there...
1
by: Sven Fischer | last post by:
After installation of Visual CSharp Studio the current settings of the source code editor are not suitable for me. The brackets are automaticlly set in front of the lines e.g. if (.......) {...
3
by: scunnybunny | last post by:
What I am trying to do is get the program to look along the array and if the first letter is ‘T’ and the last letter ‘M’ (10P7-TXL/) on the highlighted piece of tax code. #write tax bracket 1 ...
11
by: -Lost | last post by:
I was perusing some code and saw: var theForm = document.forms; if (!theForm) { theForm = document.aspnetForm; } Is this a waste of code? Or is there some instance where bracket notation...
2
by: marylipscomb | last post by:
Keeps giving an error of missing closing bracket. It is here, I have even tried adding one in different spots but still doesn't help. Function GetData(ByVal queryString As String) As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.