Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-09-2008, 09:52 PM
Member
 
Join Date: Dec 2008
Posts: 3
Rep Power: 0
jaybeeb is on a distinguished road
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


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;						
					}
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-09-2008, 10:21 PM
Senior Member
 
Join Date: Aug 2008
Posts: 374
Rep Power: 2
Supamagier is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-09-2008, 10:28 PM
Member
 
Join Date: Dec 2008
Posts: 3
Rep Power: 0
jaybeeb is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Photo Editing stekun Advanced Java 3 02-23-2010 06:11 AM
Editing & Testing Java on Mac TheRocket New To Java 7 11-22-2008 02:56 PM
JTable editing with Mouse Gajesh Tripathi AWT / Swing 0 10-11-2008 09:34 AM
jTable Cell editing mahaling_m AWT / Swing 0 06-23-2008 09:17 AM
Editing video frames in JMF russ2620 Networking 0 05-31-2008 12:26 AM


All times are GMT +2. The time now is 10:13 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org