Results 1 to 3 of 3
  1. #1
    jaybeeb is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Default Help, Editing Items in an array.

    Hi All,
    I have an array with details from a building in it. What I want to do is ask the user to enter a reg. no for a building and for them to be able to change the matching details.

    Below is my code - the edit part is case 3. It is very messy as I got lost during it


    Java Code:
    import java.util.Scanner;
    
    public class MainRates 
    {
    	
    	public static void Menu()
    	{
    		Scanner input=new Scanner(System.in);
    		int option1;
    		int option2;
    		
    		
    		Industrial indBuild[] = new Industrial[ 3 ];
    		
    		int counter = 0;
    		int editcounter1 = 0; /*editcounter
    		int editreg1;            /*edit regnumber
    		{
    		
    			do{
    				System.out.println("\n----------MAIN MENU----------\n1. Industrial\n2. Office\n3. Residential\n4. Quit\nEnter Option Number: ");
    				option1 = input.nextInt();
    		
    				switch(option1)
    				{
    					case 1:
    					{
    						System.out.println("\n-------INDUSTRIAL MENU-------");
    						System.out.println("1. Add Building");
    						System.out.println("2. Display Buildings");
    						System.out.println("3. Edit Building Details");
    						System.out.println("4. Main Menu");
    						System.out.println("Enter Option Number: ");
    						
    						
    						option2 = input.nextInt();
    						switch(option2)
    						{
    							case 1:
    							{
    								System.out.println("\n---ADD INDUSTRIAL BUILDING---");
    								Industrial ind1 = new Industrial("","",0,0.0,"");
    								System.out.println("Enter Owner: ");
    								ind1.setowner(input.next());
    								System.out.println("Enter Address: ");
    								ind1.setaddress(input.next());
    								System.out.println("Enter Phone Number: ");
    								ind1.setphoneNumber(input.nextInt());
    								System.out.println("Enter Square Metres: ");
    								ind1.setsquareMetres(input.nextDouble());
    								System.out.println("Enter Industry Type: ");
    								ind1.setindustryType(input.next());
    								
    								ind1.setcalculateRate();
    								System.out.println(ind1);
    								
    								counter = counter + 1;
    								indBuild[counter] = ind1;
    								
    								for ( int i = 0; i < indBuild.length; i++ )
    								{
    									System.out.println(indBuild[i]);
    								}
    								break;
    							}
    							
    							case 2:
    							{
    								for ( int i =0; i < indBuild.length; i++)
    								{
    									System.out.println(indBuild[i]);
    								}
    								break;
    							}
    							
    							case 3: /*edit case
    							{
    								while(editcounter1 != 0)
    		                           {
    		                           System.out.println("Enter building registration number for edit");
    		                           editreg1 = input.nextInt();
    
    		                           ind1 = setregnum(editreg1);
    
    		                           editcounter1 = 0;
    
    		                           }
    								break;
    							}
    						}
    						break;						
    					}

  2. #2
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    6

    Default

    Learn to code so that we can read it, which means, use proper tabs, where they're needed.

    Also, is an error occurring, or is the output not as it should be? Post the details, then we/I can help you.
    I die a little on the inside...
    Every time I get shot.

  3. #3
    jaybeeb is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Default

    Hi, sorry about the code - too much tabbing.

    Basically I am just not sure how to get it so I can edit the different details. the edit code is not finished the way it is now and I am just not sure what else to do to get it sorted.

Similar Threads

  1. Photo Editing
    By stekun in forum Advanced Java
    Replies: 3
    Last Post: 02-23-2010, 05:11 AM
  2. Editing & Testing Java on Mac
    By TheRocket in forum New To Java
    Replies: 7
    Last Post: 11-22-2008, 01:56 PM
  3. JTable editing with Mouse
    By Gajesh Tripathi in forum AWT / Swing
    Replies: 0
    Last Post: 10-11-2008, 08:34 AM
  4. jTable Cell editing
    By mahaling_m in forum AWT / Swing
    Replies: 0
    Last Post: 06-23-2008, 08:17 AM
  5. Editing video frames in JMF
    By russ2620 in forum Networking
    Replies: 0
    Last Post: 05-30-2008, 11:26 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
  •