Results 1 to 3 of 3
Thread: Help, Editing Items in an array.
- 12-09-2008, 08:52 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 3
- Rep Power
- 0
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; }
- 12-09-2008, 09:21 PM #2
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
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.
- 12-09-2008, 09:28 PM #3
Member
- Join Date
- Dec 2008
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Photo Editing
By stekun in forum Advanced JavaReplies: 3Last Post: 02-23-2010, 05:11 AM -
Editing & Testing Java on Mac
By TheRocket in forum New To JavaReplies: 7Last Post: 11-22-2008, 01:56 PM -
JTable editing with Mouse
By Gajesh Tripathi in forum AWT / SwingReplies: 0Last Post: 10-11-2008, 08:34 AM -
jTable Cell editing
By mahaling_m in forum AWT / SwingReplies: 0Last Post: 06-23-2008, 08:17 AM -
Editing video frames in JMF
By russ2620 in forum NetworkingReplies: 0Last Post: 05-30-2008, 11:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks