Results 1 to 2 of 2
  1. #1
    DMarsh12 is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default Simple Package Help

    I am having trouble understanding the concept of a package. To my knowledge, you can create a package, and put classes in there that could share each others properties as long as you import them. Now lets say I have a program called NorthwestCorner which is a simple supply and demand class and then I want to add on to that but do so in a different class... Here is what I did...

    Java Code:
    package Projects;
    import Projects.NorthwestCorner1;;
    public class Sales {
    	public static void main(String[] args) {
    		NorthwestCorner1 a=new NorthwestCorner1();
    Now all I want to be able to do is use all the information from the original class into this new class that I have created. For instance if I just wanted to print out the information from my original class how do I do so in this new class? Also, how do I reach the other variables from the original class in this new class...any help would be greatly appreciated.

    Here is my original class in case it helps...

    Java Code:
    package Projects;
    public class NorthwestCorner1 {
        public static void main(String[] args) {
        	System.out.println("Supply vs Demand"); // Prints out the title Supply vs Demand
        	int []s={11,10,10}; //creates an array with values 100, 200, 300
    		int []d={11,14,6}; // creates an array with values 150, 350, 100
    		int [][]table=new int[3][3]; //creates a 2D array with the values of the previous two arrays
    		for (int i=0;i<=2;i++) //creates a loop that increments by one, three times
    			System.out.println(); //creates a blank line print that is repeated three times
    			System.out.print(" "); //creates a blank space print that is repeated three times
    		for (int j=0;j<=2;j++) //creates a loop statement that increments by one three times
    		if (s[i]>d[j]){ //creates if statement comparing variables of s and d
    			table[i][j]=d[j]; //print out the d value
    			s[i]=s[i]-d[j]; // print out the x value of loop minus y value of loop
    			d[j]=0; //remaining y values equal 0
    				table[i][j]=s[i]; //print out the loop value of s
    				d[j]=d[j]-s[i]; //next y value equals the x value minus y value
    				s[i]=0; //print remaining lines 0
    		System.out.print(" "); //prints out a blank line between each number
    System.out.print(table[i][j]); //prints out the table after executing the if else loop

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

Similar Threads

  1. Simple Package Manager 0.1.1
    By java software in forum Java Software
    Replies: 0
    Last Post: 11-24-2011, 07:08 PM
  2. Package to draw simple circuit and BDD.
    By kapil1089theking in forum Java 2D
    Replies: 6
    Last Post: 11-05-2011, 10:14 PM
  3. run package inside anthor package
    By AhmedAdel in forum AWT / Swing
    Replies: 4
    Last Post: 04-20-2010, 11:52 AM
  4. Replies: 7
    Last Post: 11-09-2009, 08:51 AM
  5. Replies: 3
    Last Post: 12-12-2008, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts