aspose file tools*
The moose likes Beginning Java and the fly likes How do I get one program to take information out of another one. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I get one program to take information out of another one. " Watch "How do I get one program to take information out of another one. " New topic
Author

How do I get one program to take information out of another one.

Brandon Choate
Greenhorn

Joined: Mar 06, 2009
Posts: 14
Another day, another attempt at somehow trying to grasp the bare basics of this Java stuff.

Today's problem is this:

Program number one seems to work pretty well, no problems here:



... program number 2, however, is only half finished:



So, I'm trying to have the second program take all the methods from the previous program, and compute the value of a movie based off of that.

The problem lies with this: Viewer view = new Viewer();
It is in the same format as all the other programs I tried, but it says that it cannont find the second "Viewer" symbol. Why is this? It is written in the exact same style as similar programs of this type. What is different about this one?
This is the code that lets you take information from the "Viewer" program, right? If not, what is that code and why is the above line necessary?


Once I work that out, it should just be a question of calling up the methods like toString from the first program, right?
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296


This is the constructor for your Viewer class, it takes two Strings as arguments. In ViewerTest, you are trying to call a constructor with no parameters, but the viewer class doesn't have a constructor that takes no parameters. Either you'll have to add a constructor that takes no parameters to Viewer class, or supply some parameters when you call the constructor in ViewerTest.


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Brandon Choate
Greenhorn

Joined: Mar 06, 2009
Posts: 14
Garrett Rowe wrote:

This is the constructor for your Viewer class, it takes two Strings as arguments. In ViewerTest, you are trying to call a constructor with no parameters, but the viewer class doesn't have a constructor that takes no parameters. Either you'll have to add a constructor that takes no parameters to Viewer class, or supply some parameters when you call the constructor in ViewerTest.


Hmm, that seems to have helped a bit. Thanks!
Brandon Choate
Greenhorn

Joined: Mar 06, 2009
Posts: 14
The more things change, the more they say the same:

Program 1:



... and program 2:




Now, when I input everything it throws out:

Enter a movie code A - F: A
Is the movie rare (R) or new (N)?: N
John D. 0 3.95
John D.



Only problems are that I want the "0" to be like AN or BN or FN.... and I want the 3.95 to change with the variables.
Its kinda like the inverse problem of what I had a few minutes ago.. I think.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

Brandon Choate wrote:

Just a warning: in your constructor, you are shadowing the Customer and cost fields by a parameter and local variable respectively. In the end, you are never giving your instance fields any values.
You can fix this as follows:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I get one program to take information out of another one.