473,386 Members | 2,114 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,386 software developers and data experts.

Help with multiple file projects

Hi everyone, I have a multiple file project for a class assignment.
It consists of a class Point, then a class Polygon which uses the
Point object, then a class Picture that uses the Polygon object.
Unfortunately, I cannot compile Polygon.java, because it cannot
recgonise the Point object. Any ideas? (I'm using the Sun SDK 1.4.2)
Thanks! (By the way, the drawing package and Canvas class were
created by my instructor to make drawing to Graphics easier)

Point.java:
**
* Point.java
* ----------
* Defines the base class for the drawing exercises
*/

package csc812;

import drawing.*;

class Point
{
private int m_iXValue;
private int m_iYValue;

// Default constructor
public Point()
{
this.m_iXValue = 0;
this.m_iYValue = 0;
}

// values constructor
public Point(int x,int y)
{
this.m_iXValue = x;
this.m_iYValue = y;
}

// Copy constructor
public Point(Point P)
{
this.m_iXValue = P.m_iXValue;
this.m_iYValue = P.m_iYValue;
}

// Calculates the distance between this and a given point
public double distance(Point p)
{
return Math.sqrt((m_iXValue-p.m_iXValue)*(m_iXValue-p.m_iXValue) +
(m_iYValue-p.m_iYValue)*(m_iYValue-p.m_iYValue));
}

// Draws a line between this and the given point
public void DrawLine(Point p,Canvas c)
{
c.drawLine(m_iXValue,m_iYValue,p.m_iXValue,p.m_iYV alue);
}

// Outputs the coordinates - primarily for debugging
public void dump()
{
System.out.println("(" + m_iXValue + "," + m_iYValue + ")");
}
}

Polygon.java:
/**
* Polygon.java
* ------------
* This class uses the Point class to draw a polygon based on the
given points
* One critical assumption we make is that element 0 of the array list
is the
* starting point of the drawing
*
*/

package csc812;

import java.lang.*;
import java.util.*;
import java.awt.Color;
import drawing.*;
import csc812.Point;

class Polygon extends Point
{
// Declare an ArrayList, since we cannot predetermine how many
elements we will have
private ArrayList m_List;
// foreground colour is part of the polygon
private Color m_ForeColour;

// Default constructor
public Polygon()
{
m_List = new ArrayList();
m_ForeColour = Color.BLACK;
}

// Constructor
public Polygon(ArrayList List,Color cl)
{
if (List.contains(Point))
{
m_List = new ArrayList();
m_List = List;
}
else
{
System.out.println("Polygon constructor error");
System.out.println("The ArrayList passed is not of type Point, so
cannot construct object");
}
m_ForeColour = cl;
}

// Copy constructor
public Polygon(Polygon p)
{
m_List = new ArrayList();
m_List = p.m_List;
m_ForeColour = p.m_ForeColour;
}

// Draws the polygon
public void Display(Canvas c)
{
// Declare array for use
Point [] pArray = new Point[m_List.size()];
pArray = m_List.toArray();

c.setForegroundColor(m_ForeColour);
for (int i = 0;i < pArray.length;i++)
{
try
{
Point p1 = new Point(pArray[i]);
Point p2 = new Point(pArray[i+1]);
p1.DrawLine(p2,g);
}
catch(ArrayIndexOutOfBoundsException e)
{
break;
}
}
}

// Sets foreground colour
public void SetColour(Color f)
{
m_ForeColour = f;
}

// Output for debugging
public void Dump()
{
// Declare array for use
Point [] pArray = new Point[m_List.size()];
pArray = m_List.toArray();

for (int i = 0;i < pArray.length;i++)
{
Point p = new Point(pArray[i]);
p.Dump();
}
}
}

Error messages:
Polygon.java:19: cannot resolve symbol
symbol : class Point
location: package csc812
import csc812.Point;
^
Polygon.java:21: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
class Polygon extends Point
^
Polygon.java:38: cannot resolve symbol
symbol : variable Point
location: class csc812.Polygon
if (List.contains(Point))
^
Polygon.java:63: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point [] pArray = new Point[m_List.size()];
^
Polygon.java:63: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point [] pArray = new Point[m_List.size()];
^
Polygon.java:66: cannot resolve symbol
symbol : method setForegroundColor (java.awt.Color)
location: class drawing.Canvas
c.setForegroundColor(m_ForeColour);
^
Polygon.java:71: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p1 = new Point(pArray[i]);
^
Polygon.java:71: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p1 = new Point(pArray[i]);
^
Polygon.java:72: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p2 = new Point(pArray[i+1]);
^
Polygon.java:72: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p2 = new Point(pArray[i+1]);
^
Polygon.java:73: cannot resolve symbol
symbol : variable g
location: class csc812.Polygon
p1.DrawLine(p2,g);
^
Polygon.java:92: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point [] pArray = new Point[m_List.size()];
^
Polygon.java:92: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point [] pArray = new Point[m_List.size()];
^
Polygon.java:97: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p = new Point(pArray[i]);
^
Polygon.java:97: cannot resolve symbol
symbol : class Point
location: class csc812.Polygon
Point p = new Point(pArray[i]);
^
15 errors
Jul 17 '05 #1
3 12265
I can't see any immediate cause for the compile error. Both classes are in
the same package, so you actually don't need to import Point in Polygon, but
doing so doesn't hurt anything. I pulled your code into Eclipse, using JDK
1.3.1, commented out things like references to objects in your drawing
package, and the code compiled for me.

So there's something else at work that you're not showing; unless there's
some big difference between 1.3.1 and 1.4.0 that I don't know about; I
don't think that's the case.
Jul 17 '05 #2
"Dan Nuttle" <d_******@hotmail.com> wrote in message news:<x3******************@newsread1.news.atl.eart hlink.net>...
I can't see any immediate cause for the compile error. Both classes are in
the same package, so you actually don't need to import Point in Polygon, but
doing so doesn't hurt anything. I pulled your code into Eclipse, using JDK
1.3.1, commented out things like references to objects in your drawing
package, and the code compiled for me.

So there's something else at work that you're not showing; unless there's
some big difference between 1.3.1 and 1.4.0 that I don't know about; I
don't think that's the case.


I compiled it in the BlueJ IDE and it worked fine. Someone mentioned
that in order to compile using packages with the Sun SDK, you needed a
makefile or something like that. Anyone know how to compile multiple
..java files into a package using the Sun SDK?
Jul 17 '05 #3
he*******@hotmail.com (Herman) wrote in message news:<d6**************************@posting.google. com>...
"Dan Nuttle" <d_******@hotmail.com> wrote in message news:<x3******************@newsread1.news.atl.eart hlink.net>...
I can't see any immediate cause for the compile error. Both classes are in
the same package, so you actually don't need to import Point in Polygon, but
doing so doesn't hurt anything. I pulled your code into Eclipse, using JDK
1.3.1, commented out things like references to objects in your drawing
package, and the code compiled for me.

So there's something else at work that you're not showing; unless there's
some big difference between 1.3.1 and 1.4.0 that I don't know about; I
don't think that's the case.


I compiled it in the BlueJ IDE and it worked fine. Someone mentioned
that in order to compile using packages with the Sun SDK, you needed a
makefile or something like that. Anyone know how to compile multiple
.java files into a package using the Sun SDK?


If your class A that belongs to package P does refer to class B that
also belongs to package P, then, when you compile A.java in the
current directory P,

javac -classpath .. A.java

If you compile A.java in the current directory ../P, which is the root
directory of package P,

javac -classpath . A.java

In order to learn classpath setting for Java package, read the J2SE
basic documents for javac compiler.
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
I have one VS.NET 2003 solution that contains 3 projects. Two of the projects are ASP.NET projects each with their own .dll. The third project is a class library with its own .dll. We'll refer...
3
by: Harry Whitehouse | last post by:
I'm developing a small class which will be used in a number of distinct C# projects. This small class is undergoing constant change/refinement as I try to employ it in the different projects. ...
3
by: Galore | last post by:
Hello! I'm trying to setup an ASP.NET multiple web projects application, following the article How To Create an ASP.NET Application from Multiple Projects for Team Development. I could do it...
1
by: Jody Gelowitz | last post by:
Within ASP.NET, is it possible to use a single .vb file and have it shared (or accessed) between multiple projects without having that file being copied to each project folder? ie....
6
by: UJ | last post by:
I have a couple of files (type definitions, constants, ...) that I want to use in multiple projects. How do I make it so that I have only one copy of the file for multiple projects? If I do add...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
13
by: Paul Cheetham | last post by:
Hi, I have two projects where I want to use the same source file in each project. If I add the file to each project, then a local copy is made. I want to be able to have a single source file...
3
by: Claudio Pacciarini | last post by:
Hi everyone, I have a question about .NET code sharing and reuse, and also about application design best practices / guidelines. Currently, we have many different .NET projects in source...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.