Please help with the following:
Code in Java keep the code as simple as possible do not use arrays nor parseItnt StringBuilder etc keep it very simple.
Class TextEdit
In text editing class. Its constructor it receives a string. The string will be stored in a field called initialValue using proper setter methods and proper documentation for Each of the methods.
This class also contains another String field called: ”mixedResult” which is only defined globally and will be initialized using a method in the future in the main class namely the mix method.
The public String toToken() method is a method that will use the initialValue field and it for the letter ’p’ or the letter ’A’. If it finds the letter, every element on the left side of the found letter will be stored in another string and returned. Example: If the initialValue was: ”This is a possible resource allocation”. The returning String will be: ”possible resource allocation”.
Use control statements here iterate through the string using a counter control statement). If both ’A’ and ’p’ were present, it will only do it for the first occurrence and then break. You need to have a unitTest for this method.
The other method supported by this class (except all the setters and getters, Tostring and constructor) is the mix method. public String mix(String s) will receive as input a string s and will do the following. It will first find the minimum length between the initialValue and the string s (to avoid index out of bound errors). Then it will loop from one to the mixLen doing what is described below.
This method will initialize the mixedResult variable. For each even position it will take the value of the initialValue String and for all of the odd positions it will take the value of the String s. Example : initialValue=”hello” , s= ”Lamp” then mixedResult=halp.
For this method as well you will need a unit test.
Class Country
This class consists of the following fields.
String name
double area
String president
String continent
You will need to develop proper setters, getters, constructors, and toString methods to set the elements of this class the way you like. (No unit test needed) )
Class City
The class contains the following fields
String name
int regionalCode
Country country
Use proper setters and getters to initialize the fields. The class also contains a getCountriesPresident() method which will return the name of the president of the country.
Main
In the main method create an object of the class texTEdit. Ask the user to input the initialValue variable and initialize the fields to the given input. Then in the main method call the toToken and mix methods. For the input of the mix method, ask the user to input a string.
Initialize two countries and then initialize four cities (no need to ask the user for input, you can fill them manually using the constructors or setters). Then call the getCoutnriesPresident method to print the name of each one of the presidents.