Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I don\'t how to do the BankPaser, requirement is below. The BankParser class is

ID: 3549655 • Letter: I

Question

I don't how to do the BankPaser, requirement is below.


The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method:

public static Bank bankParser(String lineToParse)

The bankParser method's argument will be a string in the following format:

bankName/bankID/city,state

A real example of this string would be:

Bank Arizona/10001/Phoenix,AZ

The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it.

The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method:

public static Bank bankParser(String lineToParse)

The bankParser method's argument will be a string in the following format:

bankName/bankID/city,state

A real example of this string would be:

Bank Arizona/10001/Phoenix,AZ

The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it.

The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method:

public static Bank bankParser(String lineToParse)

The bankParser method's argument will be a string in the following format:

bankName/bankID/city,state

A real example of this string would be:

Bank Arizona/10001/Phoenix,AZ

The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it.


The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method: public static Bank bankParser(String lineToParse) The bankParser method's argument will be a string in the following format: bankName/bankID/city,state A real example of this string would be: Bank Arizona/10001/Phoenix,AZ The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it. The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method: public static Bank bankParser(String lineToParse) The bankParser method's argument will be a string in the following format: bankName/bankID/city,state A real example of this string would be: Bank Arizona/10001/Phoenix,AZ The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it. The BankParser class is a utility class that will be used to create bank objects from a string. The BankParser class cannot be instantiated. It has the following method: public static Bank bankParser(String lineToParse) The bankParser method's argument will be a string in the following format: bankName/bankID/city,state A real example of this string would be: Bank Arizona/10001/Phoenix,AZ The bankParser method will parse this string, pull out the information, create a new bank object, set the attributes of the object, and return it.

Explanation / Answer

//---------------------------------------------------BankParser.java------------------------------------------

public class BankParser {

public static Bank bankParser(String parseString){

Bank bank = new Bank();

int nameInd, idInd, cityInd;

nameInd = parseString.indexOf("/");

idInd = parseString.indexOf("/", nameInd+1);

cityInd = parseString.indexOf(",", idInd+1);

  

bank.setBankName(parseString.substring(0, nameInd));

bank.setBankID(parseString.substring(nameInd+1, idInd));

bank.setBankAddress(parseString.substring(idInd+1, cityInd),

parseString.substring(cityInd+1) );

return bank;

}

}

//----------------------------------------------------class Bank.java---------------------------------------------


public class Bank {

private String bankName;

private String bankID;

private Address bankAddress;

  

public Bank(){

bankName = null;

bankID = null;

bankAddress = new Address();

}

public void setBankName(String s){

bankName = s;

}

public void setBankID(String s){

bankID = s;

}

public void setBankAddress(String city, String state){

bankAddress.setCity(city);

bankAddress.setState(state);

}

public String toString(){

return bankName + " " + bankID + " " + bankAddress;

}

}

//----------------------------------------------------class Address.java---------------------------------------------

public class Address {

private String city;

private String state;

  

public Address(){

city = null;

state = null;

}

public String getCity(){

return city;

}

public String getState(){

return state;

}

public void setCity(String s){

city = s;

}

public void setState(String s){

state = s;

}

public String toString(){

return city + ", " + state + " ";

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote