Just want to know it this small code is right

Hello everyone, im back :P
well, i've been doing exercises, but i don't have the solution yet...so could you tell me if this code is right? thanks.
About the constructors etc..i think its right, but i not sure about the last method ( distanceFromTwoPoints() )
If i'd like to test this class, i would ask for 4 coord. (x1,y1) and (x2, y2)..
And solved the distance between those two points..well
I don't understand..
On that code how can i calculate the distance from two points if i just have x1 and y1, i mean ...when i wrote that boolean method ( if the two points are equal) the the "p" variable reference is pointing to x1 and y1 , right? maybe that boolean method is wrong too, cuz i want to compare (x1, y1 ) with (x2, y2) well....when i wrote :
this.x1 == p.x1 etc both are references to x1 and y1, so returns always true.
Do i need to write a setMethod to change the values ?
Is that code comparing two points? thats all i want to know...if yes, so how can i test it?
public class Point {
     private double x1;
     private double y1;
     public Point(final double x1, final double y1){
          this.x1 = x1;
          this.y1 = y1;          
     public double getX1() {
          return x1;
     public double getY2() {
          return y1;
     public boolean isEqual(final Point p){
          return (this.x1 == p.x1 && this.y1 == p.y1);
     public double distanceFrom2Points (int x1, int y2, Point p){
          return Math.sqrt((this.x1 - p.x1)*(this.x1 - p.x1) + (this.y1 - p.y1)*(this.y1 - p.y1));
I think this code is just working with two coord. x1 and y1 :S where do i put x2 and y2?
"p" is a reference to the x1 and y1 variables, so where are the x2 and y2?
im confused :P
thanks

public class Point {
     private double x;
     private double y;
     public Point(final double x, final double y){
          this.x = x;
          this.y = y;          
     public double getX() {
          return x;
     public double getY() {
          return y;
     public boolean isEqual(final Point p){
          return (this.x == p.x && this.y == p.y);
     public double distanceFrom2Points ( Point p){
return Math.sqrt((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y));
public class TestingPoint {
     public static void main(String[] args) {
          System.out.print("X1: ");
          double x1 = Teclado.doubleLido();
          System.out.print("Y1: ");
          double y1 = Teclado.doubleLido();  
          //Teclad.intLido() reads from the console, something like:
         //Keyboard.intRead(); we use that.
          System.out.print("X2: ");
          double x2 = Teclado.doubleLido();
          System.out.print("Y2: ");
          double y2 = Teclado.doubleLido();
          Point p1 = new Point(x1, y1);
          Point p2 = new Point(x2, y2);
    double distance = p2.distanceFrom2Points(p1.distanceFrom2Points
                                               (x1,x2));
     System.out.println("The distance is "+distance);
}the compilation ERROR says: The method distanceFrom2Points(Point) in the type Point is not applicable for the arguments (double, double)
these are the two classes.
What is wrong ?
thanks!

Similar Messages

  • I have an eight GB iPhone 3G, but when on iTunes on my Mac, it says my phone only has 6.9 GB of space total. I just want to know why this is, and if I am able to get a new phone because of malfunction.

    I have an eight (8) GB iPhone 3G, but when on iTunes on my Mac, it says my phone only has 6.9 GB of space total. I just want to know why this is, and if I am able to get a new phone because of malfunction.  Thanks!

    You don't have a malfunction.  Read this:  How Mac OS X and iOS report storage capacity, http://support.apple.com/kb/TS2419

  • I just want to know if this site came to me thru an email today is genuine or scam which is more likely

    http://globalpromotion.internetsavingassurvey.com/home.html

    Thanks free56 and I knew that this was not the best forum but with no way contacting Mozilla team, or at least me failing to locate it, that was my best guess. Thanks again anyway.

  • HT4061 I got a brand new iPhone 4S on contract last week and since I've had it it's been over heating and it's turned itself off once and every now and then the screen flickers I just wanted to know is this a common thing as I've never had an iPhone befor

    My new iPhone 4S that I have had a for about a week keeps over heating a lot and its turned itself off once and I couldn't turn it on for over half an hour,also my screen flickers from time to time and I'm not sure what to do as I not had an iPhone before can anybody help me please I would be very greatful.

    No, it's not normal.
    Basic troubleshooting from the User's Guide is reset, restart, restore (first from backup then as new).
    Frankly though, considering it's new, take it back to Apple.

  • I just want to know why money was taken out mi bank account,i still have a itunes balence and used a gift card.id love someone 2 call me about this but i never get thru to you

    i just want to know why money was taken out mi bank account,i still have a itunes balence and used a gift card.id love someone 2 call me about this but i never get thru to you

    This is a User to User Forum... You are not addressing Apple Here...
    Suggest you use this link to Contact iTunes Customer Service
    Apple  Support  iTunes Store  Contact Us

  • My iPhone is skipping back to the start of a song every time I unlock it, especially when I am replying to a text message, this is very frustrating and just want to know if it is a simple bug that will be dealt with in the next update?

    My iPhone is skipping back to the start of a song every time I unlock it, especially when I am replying to a text message, this is very frustrating and just want to know if it is a simple bug that will be dealt with in the next update?

    Assuming the phone isn't jailbroken, the basic steps (as needed) are:
    Restart phone (you already did this)
    Reset phone
    Restore phone in iTunes using a backup
    Restore in iTunes as new, without using a backup
    See appendix B of the User Guide for details
    http://manuals.info.apple.com/en_US/iPhone_iOS4_User_Guide.pdf
    If your phone is jailbroken, this is the most frequent cause of the problems you described.  Restoring could permanently brick the phone.
    Note that your iOS is old and the current version is 4.2.8.  It's odd that it wasn't updated when your activated your phone in iTunes, being that you got it last Friday.

  • I have an ipad 2 but got locked, just want to know if it is possible unlocked

    hello
    a question, I have an ipad 2 but got locked, just want to know if it is possible unlocked

    How can I unlock my iPad if I forgot the passcode?
    http://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.htmlhttp://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.html
    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tbhttp://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Devicehttp://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htmhttp://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    You may have to do this several times.
    Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just canceling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • What this small code does? And how do I do it in Unicode.

    Hi.
    I got the following code and I really don't know what it does or even why. All I know It's not UC enabled ( since it's uxinf the type x).
    I was thinking I might be converting from ascii representation to text or something like that but I'm not that sure.
    FORM TRANSLATE_FIELD USING    STRING_TRAN
                         CHANGING STRING1.
      DATA: STRING(255),
             len1(3) type i,
             LEN(3)  TYPE I,
             NUM(3)  TYPE I,
             I(3)    TYPE I.
      DATA: C VALUE 'A',
            X TYPE X.
      FIELD-SYMBOLS:<fc> type c.
      STRING = STRING_TRAN.
      len1 = strlen( STRING ).
      LEN = 0.
      NUM = 0.
      while len < len1.
        i = STRING+len(3).
        move i to x.
        assign x to <fc> casting type c.
        move <fc> to c.
        MOVE C TO STRING1+NUM.
        len = len + 3.
        NUM = NUM + 1.
      endwhile.
    ENDFORM.                    " TRANSLATE_FIELD
    Thanks
    Ariel

    Hi.
    I want to make this small code UC enabled. Since there is a move of TYPE x into char this is not OK at the mopment.
    the problem is I don't really know or understand how to convert itr to UC enabled program.
    You can notice it takes clusters of 3 chars (bytes ?) long and convert them to char.
    For example 101 = e 100 = d 099 = c.... :-> 101099101 -> ece .
    Thanks
    Ariel

  • Just wanted to know weather the Infinite loop Is proper?

    hi, I wrote an infinite loop.here's the code
    import acm.program.*;
    public class myFirstInfiniteLoop extends DialogProgram{
    public void run() {
    int x=0;     
         while (x<=0){
    println("this just might be an Infinite loop.");
    break;
    println("were out of the Infinit loop");
      just wanted to know weather the code would function properly.
    Thanks! :D

    Parastar wrote:
    When I tried It the dialog box first came up with the text "this just might be an infinite loop" after clicking okay the second dialog box came up stating "were out of the Infinite loop"Do you understand why?
    now If I removed the break; form the while loop the dialog box's keep on coming even after I pressed okay,does that mean the infinite loop Is coded well?What is your guess here?
    And just as a side note: And infinite loop is easily implemented using "while(+expression+) { ... your code ...}" where "+expression+" evaluates to true. You are using "x>=0" as the expression. There is a much simpler expression around, that always evaluates to true: it's simply "true". This way you don't need the variable x.

  • On my iPhone when I go on phone to view my contacts on the top left corner there is a circle with a arrow ( like a refresh icon ), just want to know what is it?

    On my iPhone when I go on phone to view my contacts on the top left corner there is a circle with a arrow ( like a refresh icon ), just want to know what is it?

    That's exactly what it does, refresh your contacts. As an example if you add a contact on your Mac or iPad and you use iCloud to sync them altogether, then this can be used to refresh the contacts on your iPhone. 

  • I just want to know that if I buy an iphone 4S here in melbourne can i use it in china? i don`t know whether it`s locked or not and i don`t know what`s the network in china as well. Can somebody please help?I am really in a hurry to know it. Thanks a lot.

    I just want to know that if I buy an iphone 4S here in melbourne can i use it in china?
    i don`t know whether it`s locked or not and i don`t know what`s the network in china as well.
    Can somebody please help?
    I am really in a hurry to know it.
    Thanks a lot.
    P.S: For the iphone 4S. is there any difference for the one from online shop or the actual store?

    iPhones purchased from the online Apple Store in Australia will be unlocked. To the best of my knowledge, unlocked iPhone are not available from the physical Apple Stores at this time, though you can call the Apple Store in Melbourne and inquire.
    Note that the warranty on iPhones is not international, so if you purchase an iPhone in Australia and it needs service, you would have to ship the iPhone to someone in Australia to take or send to Apple for service and then ship it back to you.
    Regards.
    (Note for any readers: this is an old thread and I posted before noticing the date, but decided to leave my reply in case anyone else finds the thread and has the same question).

  • Does anyone know what this error code means?My itunes will not open, no matter how many times i downlaod and restore it??? "The procedure entry point xmlITexTextReaderName could not be located in the dynamic link library libxml2.dlll."

    Does anyone know what this error code means?My itunes will not even open, no matter how many times i downlaod and restore it??? "The procedure entry point xmlITexTextReaderName could not be located in the dynamic link library libxml2.dlll." Please let me know if your know anything! It is greatly apprecitated!

    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. Head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (Although the procedure is for Vista and 7 and you've got XP, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever since I did that my itunes won't open any more.  Itunes starts but before anything loads a

  • Just wanted to know if its possible to password Protect IPhoto on iphone

    Just wanted to know if its possible to password Protect IPhoto itself from someone just being able to click on my IPhoto Application and have it opened and be able to see all my photos etc etc or even to password Protect the Events also is this possible and how please need help
    i have iphone4s
    tankyou

    No. You can password protect the entire iPhone in Settings but not individual apps.

  • HT4796 Hi, I've just bought a new Macbook Pro and started migrating from PC but the remaining time is about 70 hours long, I just wanted to know if that timing is normal and if not, does leaving running my MacBook that time can affect it?

    Hi, I've just bought a new Macbook Pro and started migrating from PC but the remaining time is about 70 hours long, I just wanted to know if that timing is normal and if not, does leaving running my MacBook that time can affect it?

    70 hours...  no, it's not normal but it can't hurt your Mac to be running for that amount of time.
    Try this support article > OS X Mavericks: Transfer your info from a PC

  • I just want to know what Apple computer to get to play Civilization V down loaded from the App store.

    I just want to know what Apple computer to get to play Civilization V down loaded from the App store.
    The game Civ5 processes a turn in single core mode. It says “please wait” while it processes a turn. If the intel i7 CPU is “fourth generation” it is twice as fast for civ5 turn processing. It does not matter if you have more memory or a better graphics chip. So, I can get a smaller cheeper Apple computer as long as it is fourth generation. I tested three new iMacs, two new MacPros and two mac minis.
    See:
    http://apolyton.net/showthread.php/193302-Civ-5-Processor-performance-analyzis-a t-Gamespot
    I have looked at that darned “please wait” message for years. Now it can be 60 seconds on a new MacPro6,1 or late 2012 Mac mini and 30 seconds on a new iMac. Even the 21.5 iMac 3.1 GHz has 3.9 GHz turbo boost for single core and it is supposed to be fourth generation.
    Some of that does not seem to true for the new 21.5 inch iMac I just tested (Fusion drive). Mac Mini 54 seconds 21.5 iMac 49 seconds.
      Cliff Nelson

    Legality aside (I'm not a lawyer and have no opinion on the matter) in order to make a purchase of an iPhone 5 you would need to travel to a country where they are for sale and purchase it there. Be sure to get one that is officially unlocked or you would not be able to use it with your cell carrier. Be sure that your carrier supports use of the iPhone before you buy. Also note that the warranty of the iPhone is only valid in the country of purchase.
    Appe does not ship outside of the countries where it sells the phones.

Maybe you are looking for

  • New features good!  Trusty old features...missing.

    Flash CS4... I don't use the HELP functionality except for ONE thing, a reference guide for AS3 classes. In CS3 it sat in a tab right next to my ACTIONS tab and I would toggle back and forth between the two as a part of my work process. Now, the help

  • Six plus keeps restarting itself

    I bought a new iPhone six plus about a month ago. Recently, it has been turning on and off on its own, and now it won't turn back on at all. I tried the hard restart, but that did not work. Also, I tried connecting it with my laptop and it still will

  • Function module not allowed: AFS_RETAIL_ARTMAS_IDOC_INPUT.

    Dear Expert,    I have a problem when I use ALE. I found error message of inbound in target system have a error status 51. Function module not allowed: AFS_RETAIL_ARTMAS_IDOC_INPUT. message type is MATMAS. and i want to distribute Material master fro

  • Can the form attachment files be included in the notification e-mail?

    Can the form attachment files be included in the notification e-mail? Best regards

  • Payslip in PDF through email

    Dear All i have written the program for send payslip through email and its working fine But problem is that i am not getting the correct format in PDF Regards Arun