Veteran Member
Join Date: May 2004
Location: Promise Land of Trustafarians
|
So, I have an error that doesn't seem to make any sense. I'm simply trying to create a new instance of a class (Payment.java) inside another class (VendingMachine.java).
Code:
from VendingMachine
private void pay(double price, boolean gui) {
Scanner Sc = new Scanner(in);
DecimalFormat ff = new DecimalFormat("0.00");
double paid=0.0;
Payment pay = new Payment(price); Now, the compile error says:Code:
VendingMachine.java:89: cannot find symbol
symbol : constructor Payment(double)
location: class VendingMachine.Payment
pay = new Payment(price);
^
1 error Now, if I remove the "price" argument from the line creating the new instance in VendingMachine, it compiles, but obviously doesn't work, as I never wrote the default constructor. The constructor in Payment is:Code:
public class Payment extends JFrame {
private variables
public Payment(double price) {
super("Insert Coins"); Obviously, these aren't full excerpts of code. But does anyone have any idea why this doesn't compile? |
quote |
Veteran Member
Join Date: May 2004
|
You have the proper 'import Payment', right?
|
quote |
Veteran Member
Join Date: May 2004
Location: Promise Land of Trustafarians
|
They're in the same folder, so I didn't think it was necessary, but I'll give it a shot.
And... same error. edit: Okay, I've fixed it. I didn't realize there was already a Payment class in Java, which explains the error, I guess. I changed the name of my class to something else and it works fine now. Last edited by Ryan : 2007-11-16 at 22:19. |
quote |
Posting Rules | Navigation |
|
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
iPhone: Running List of Problems | Kraetos | Apple Products | 206 | 2007-07-28 13:22 |
10.4.9 now available in SW Update | FFL | Apple Products | 118 | 2007-04-28 22:34 |
please explain 'class' in PHP | nassau | Programmer's Nook | 12 | 2006-07-13 13:36 |
Problems creating pdf files from Excel 2004 | fwtong | Genius Bar | 5 | 2006-06-19 22:35 |
Very disappointed by my G5 and Java... | nicolas_bol | Apple Products | 69 | 2006-04-29 18:15 |