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


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.

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here