0

In drjava I'm trying to acquire pictures in hold them in the array, and then print out a description of each picture. Right now everything compiles but when I run it has me choose the folder that contains the pictures and then the interactions pane disappears. The code I have so far is in my House app for acquiring the pictures and printing the descriptions is

SSCCEE

HOUSE.java

public class House
{
  String owner;
  public final static int CAPACITY = 6;
  Picture[ ] pictArray = new Picture[CAPACITY];

  public House(String pString)
  {
    this.owner = pString;
  }
  public String toString()
  {
    return("The House owned by " + this.owner);
  }
  public void acquire( int position, Picture pRef )
  {
    this.pictArray[ position ] = pRef;
  }
  public void printPictures()
  {
    for (int i=0; i < this.pictArray.length;i++)
    {
      System.out.print("The Picture in position " + i + " is ");
      System.out.println( this.pictArray[ i ]);
    }
  }
  public void swap( int positionA, int positionB )
  {
    System.out.println("NOTHING DONE.  THIS IS JUST A swap's STUB");

  }
  public void showOff()
  {
    System.out.println("NOTHING DONE.  THIS IS JUST showOff's STUB");

  }
}

Test.java

import java.util.Scanner;
public class Test
{
  public static void main(String[] a)
  {
    House h = new House("Justin Chaisetseree");
    Scanner sc = new Scanner(System.in);
    FileChooser.pickMediaPath();
    for( int i = 0; i < 6; i++)
    {
      h.acquire(i,new Picture(FileChooser.pickAFile()));
    }
    h.printPictures();
    h.showOff();
    Boolean done = false;
    while( ! done )
    {
      System.out.println("Which two do you want to swap?");
      System.out.print("Type in two numbers from 0 to ");
      System.out.print( 5 );
      System.out.println(" or two -1s to stop.");
      int userInput1 = sc.nextInt();
      int userInput2 = sc.nextInt();
      if( userInput1 < 0 || userInput2 < 0)
      {
        done = true;
      }
      else
      {
        h.swap( userInput1, userInput2 );
      }
    }
    h.showOff();      
  }
}
user3060040
  • 77
  • 1
  • 9
  • 2
    1) For better help sooner, post an [SSCCE](http://sscce.org/). 2) One way to get image(s) for an example is to hot-link to the images seen in [this answer](http://stackoverflow.com/a/19209651/418556). 3) *"the interactions pane disappears"* What 'interactions pane'?!? That statement alone implies to me a GUI, whereas the code snippets above are more typical of an app. run from the command line. Point 1 X 1000 - post an SSCCE. – Andrew Thompson Dec 13 '13 at 21:12
  • I guess I was unclear. I can set the mediapath, but then I cannot choose the picture files. An interactions icon remains open on my Dock but isnt really there, and when I hover over Interactions in drjava its just perpetually loading – user3060040 Dec 13 '13 at 22:37
  • *"I guess I was unclear."* That makes two of us. Which part of *"For better help sooner, post an [SSCCE](http://sscce.org/)."* do you **not** understand? – Andrew Thompson Dec 13 '13 at 22:42
  • Sorry, I am new at this and thought my problem might have been solved easier. I think I edited it so that it is an "SSCCEE" – user3060040 Dec 13 '13 at 22:59
  • *"I think I edited it so that it is an "SSCCEE""* Think again. An SSCCE has only one source file and no more than one `public` class in that file. Further, if I change the code to be that way, it ***still*** shows compilation errors. Please make use of the SSCCE Text Based Compiler to ensure that an SSCCE of a run-time problem actually compiles cleanly! – Andrew Thompson Dec 13 '13 at 23:03
  • I do not know how to make it work by putting them all in a single file. The two seperate files compile for me but oh well thanks anyway. – user3060040 Dec 13 '13 at 23:08
  • *"The two seperate files compile for me.."* That is probably because you have defined a `Ship` class in your IDE. Try pulling your head out of your IDE for a minute, and stepping way back from the problem - way back. To do that, try the following. Create a new project in your editor. Copy/paste that code you posted. Compile it! – Andrew Thompson Dec 13 '13 at 23:11

0 Answers0