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.Proper setters, getters, constructors, and toString methods for all of the classes    Class TextEdit  This is a text editing class. In 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 .  The 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. For 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 .   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.    Class Country  This class consists of private fields.  String name double area String president  String continent  You will need to develop proper setters, getters, constructor, and toString methods to set the elements of this class the way you like.  Class city This class consists of private 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 constr

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

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.Proper setters, getters, constructors, and toString methods for all of the classes 

 

Class TextEdit 

This is a text editing class. In 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 . 

The 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. For 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 .  

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. 

 

Class Country 

This class consists of private fields. 

String name
double area
String president 

String continent 

You will need to develop proper setters, getters, constructor, and toString methods to set the elements of this class the way you like. 

Class city

This class consists of private 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.  

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT