473,385 Members | 1,402 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,385 software developers and data experts.

Override Problem

Hello, I am trying to extend my class Point in class Point2D, but I always get an error that it can not find the symbol Point. This is my code:
Expand|Select|Wrap|Line Numbers
  1. package Package1DShapes;// a folder that has class point and class algebra inside
  2.  
  3. public class Point
  4. {
  5.   public int x;
  6.  
  7.   public Point(int x)
  8.   {
  9.     this.x = x;
  10.     setPoint(x);
  11.   }
  12.  
  13.   public void setPoint(int x)
  14.   {
  15.     this.x = x;
  16.     getPoint();
  17.   }
  18.  
  19.   public int getPoint()
  20.   {
  21.     return x;
  22.   }
  23.  
  24.   public String toString()
  25.   {
  26.     return ("x =" + x);
  27.   }
  28.  
  29.   public boolean equals(Object otherObject)
  30.   {
  31.     if (otherObject == null)
  32.     {
  33.       return false;
  34.     }
  35.     else if(getClass() != otherObject.getClass())
  36.     {
  37.       return false;
  38.     }
  39.     else
  40.     {
  41.       Point otherPoint = (Point)otherObject;
  42.       return(x == otherPoint.x);
  43.     }
  44.    }
  45. }
  46.  
  47.  
  48. package Package2DShapes;
  49. import Package1DShapes.*;
  50.  
  51. public class Point2D extends Point
  52. {
  53.   public int y;
  54.  
  55.   public Point2D(int x, int y)
  56.   {
  57.     super.setPoint(x);
  58.     setPoint2D(y);
  59.   }
  60.  
  61.   public void setPoint2D(int y)
  62.   {
  63.     this.y = y;
  64.     getPoint2D();
  65.   }
  66.  
  67.   public int getPoint2D()
  68.   {
  69.     return y;
  70.   }
  71.  
  72.   public boolean equals(Object otherObject)
  73.   {
  74.     if (otherObject == null)
  75.     {
  76.       return false;
  77.     }
  78.     else if(getClass() != otherObject.getClass())
  79.     {
  80.       return false;
  81.     }
  82.     else
  83.     {
  84.       Point otherPoint = (Point)otherObject;
  85.       Point2D otherPoint2D = (Point2D)otherObject;
  86.       return(x == otherPoint.x);
  87.       return(y == otherPoint2D.y);
  88.     }
  89.    }
  90.  
  91.   public String toString()
  92.   {
  93.     return ("x =" + x);
  94.     return ("y =" + y);
  95.   }
  96.  
  97.  
  98. }
  99.  
  100.  
Thanks!
Nov 13 '08 #1
1 1184
r035198x
13,262 8TB
1.) Make sure you are posting in the correct forum next time.
2.) Use code tags when posting code.
3.) Your Point.class file needs to be made available on the classpath when you compile your Point2D.java file.
Nov 13 '08 #2

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

Similar topics

22
by: Ruben Van Havermaet | last post by:
Hi, I have a problem using member functions in derived classes that override virtual member functions of base classes. The following pieces of (simplified) code don't work. Can anybody give...
1
by: Tony Johansson | last post by:
Hello experts! I know it's easy to override when you have inheritance. But if you instead use object composition having a pointer to a class X. If you want to override when having this object...
7
by: Thomas Kehl | last post by:
Hello. I provided a class, which derives from the class DataView. The only thing, which I would like to do in this class am to overwrite the Property COUNT. I wars it however simply not. I get...
2
by: ~toki | last post by:
How can i take the control of the key events in Class2 ? This is the code snipped that i'd tried (after try some others): public class Main : System.Windows.Forms.Form { protected virtual...
11
by: songie D | last post by:
Does c# support overriding by name and not signature For instance I am building a custom collection class, that ca only take a certain type of object For this, I have added an override for add...
15
by: Cliff_Harker | last post by:
Why can't I do this in C# public class A { public A virtual whatever( A a ) { } } public class B : A
8
by: bdeviled | last post by:
I am deploying to a web environment that uses load balancing and to insure that sessions persist across servers, the environment uses SQL to manage sessions. The machine.config file determines how...
2
by: Jason Huang | last post by:
Hi, In my C# Windows form MyForm, it has a function MyFunction which is a big function and has lots of codes. I am thinking the override for MyFunction, one MyFunction has a parameter which...
4
by: Kevin Frey | last post by:
I have the following situation: Assembly #1: class NativeSearchCriteria // NOTE: a native class { }; public ref class TheBaseClass {
2
by: Ste | last post by:
Good morning, I have a bindinglist of my custom objects and need to check, before adding items, if an item exists in list and then cancel inserting. I have tried to create an object that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.