4 Replies - 796 Views - Last Post: 21 August 2011 - 12:07 PM Rate Topic: -----

#1 monkeyjam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-August 11

phone dissector with driver. Multiple errors, help!

Posted 21 August 2011 - 11:27 AM

I am getting multiple errors, about 15, with my code. I can not understand why. Could someone guide me in the right direction?

Here is my code:
/**************************************************************
* RFDissector.Java
* 
*
* This program will dissect a phone number and give the output
* for the country code, area code, prefix, and line number.
**************************************************************/

public class RFDissector
{

	String [] temp;	//String Split
	String colonSeparated;	//string will hold the phone number
	String countryCode;	//country code
	int areaCode;	//area code
	int prefix;	//prefix
	int number;	//line number

	//mutators

	public RFDissector(String colonSeparated)
	{
		this.colonSeparated = ColonSeparted;
		temp = colonSeparated.split(":");
	}
	public String getPhoneNumber()
	{
		return  colonSeparated;
	}
	public String getPhoneNumber(1)
	{
		countryCode=colonSeparated.subString(0,colonSeparated.indexOf(":"));
	}
	public String getPhoneNumber(2)
	{
		String AreaCode = colonSeparated.subString(countryCode + 1, colonSeparated.indexOf(":"));
		areaCode = Integer.parseInt(AreaCode);
	}
	public String getPhoneNumber(3)
	{
		String prefix= colonSeparated.subString(countryCode + 2, colonSeparated.indexOf(":"));
			prefix = Integer.parseInt(prefix);
	}

	public String getPhoneNumber(4)
	{
		String number = colonSeparated.subString(countryCode + 3, colonSeparated.indexOf(":"));
		number = Integer.parseInt(number);
	}





}//end public class RFDissector



Here is my driver:
public class RFProg1
{
	public static void main (String[] args)
	{
	  RFDissector phone = new RFDissector("1:919:882:5000");

		  System.out.println(phone.getPhoneNumber());

		  System.out.println(phone.getPhoneNumber(4));

		  System.out.println(phone.getPhoneNumber(1));

		  System.out.println(phone.getPhoneNumber(3));

		  System.out.println(phone.getPhoneNumber(2));

	} // end main
}// end class



Is This A Good Question/Topic? 0
  • +

Replies To: phone dissector with driver. Multiple errors, help!

#2 giggly kisses  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 80
  • View blog
  • Posts: 391
  • Joined: 29-March 09

Re: phone dissector with driver. Multiple errors, help!

Posted 21 August 2011 - 11:35 AM

What errors are you getting? What line are they on? Can you copy and paste the exact errors you're getting?

This post has been edited by giggly kisses: 21 August 2011 - 11:35 AM

Was This Post Helpful? 0
  • +
  • -

#3 monkeyjam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-August 11

Re: phone dissector with driver. Multiple errors, help!

Posted 21 August 2011 - 11:59 AM

yes I can!

\RFDissector.java:30: illegal start of type
	public String getPhoneNumber(1)
	                             ^
.\RFDissector.java:34: illegal start of type
	public String getPhoneNumber(2)
	                             ^
.\RFDissector.java:39: illegal start of type
	public String getPhoneNumber(3)
	                             ^
.\RFDissector.java:45: illegal start of type
	public String getPhoneNumber(4)
	                             ^
.\RFDissector.java:23: cannot find symbol
symbol  : variable ColonSeparted
location: class RFDissector
		this.colonSeparated = ColonSeparted;
		                      ^
.\RFDissector.java:32: cannot find symbol
symbol  : method subString(int,int)
location: class java.lang.String
		countryCode=colonSeparated.subString(0,colonSeparated.indexOf(":"));
		                          ^
.\RFDissector.java:36: cannot find symbol
symbol  : method subString(java.lang.String,int)
location: class java.lang.String
		String AreaCode = colonSeparated.subString(countryCode + 1, colonSeparated.indexOf(":"));
		                                ^
.\RFDissector.java:41: cannot find symbol
symbol  : method subString(java.lang.String,int)
location: class java.lang.String
		String prefix= colonSeparated.subString(countryCode + 2, colonSeparated.indexOf(":"));
		                             ^
.\RFDissector.java:42: incompatible types
found   : int
required: java.lang.String
			prefix = Integer.parseInt(prefix);
			                         ^
.\RFDissector.java:47: cannot find symbol
symbol  : method subString(java.lang.String,int)
location: class java.lang.String
		String number = colonSeparated.subString(countryCode + 3, colonSeparated.indexOf(":"));
		                              ^
.\RFDissector.java:48: incompatible types
found   : int
required: java.lang.String
		number = Integer.parseInt(number);
		                         ^
11 errors

Tool completed with exit code 1


Was This Post Helpful? 0
  • +
  • -

#4 CasiOo  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1379
  • Posts: 3,041
  • Joined: 05-April 11

Re: phone dissector with driver. Multiple errors, help!

Posted 21 August 2011 - 11:59 AM

You do not define a method this way
public String getPhoneNumber(1)

instead it would look like
public String getPhoneNumber( int i )

Then you check the value of i (if 1, 2, 3 etc.). You will also have to remove all of your repeating methods that don't work, this is the only one needed.
Was This Post Helpful? 0
  • +
  • -

#5 monkeyjam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 21-August 11

Re: phone dissector with driver. Multiple errors, help!

Posted 21 August 2011 - 12:07 PM

ok so it would look like this?
public String getPhoneNumber(int i)
	{
		countryCode=colonSeparated.subString(0,colonSeparated.indexOf(":"));
	}
	



When you say remove the repeating methods, dont I need to have a method for those? I.E. areaCode, prefix, number?

what would become of those methods? Or do I just delete them all together?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1