You must create two java files one is called


You must create two Java files. One is called LastNameFirstNameWeek7Prog.java, and the other is called ComputerMicrobe.java.
Ensure you include ALL the java files required to make your program compile and run. I would like to see your .java files only.)
Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.
Only submit the .java files needed to make the program run. Do not submit the .class file or any other file.

Style Components
Include properly formatted prologue, comments, indenting, and other style elements as shown in Chapter 2 starting page 64 and Appendix 5 page 881-892.

LastNameFirstNameWeek7Prog.java
Write a driver class that uses the ComputerMicrobe class. This driver class will use the main method provided below exactly. You must copy it inside your driver class and not change it. Any change in the main method will incur in deducted points.
public static void main (String[] args) {
Scanner stdIn = new Scanner(System.in);
String name; //Auxiliar ComputerMicrobe name
String dNACode; //Auxiliar ComputerMicrobe DNA Code
ComputerMicrobe a, b, c; // ComputerMicrobe objects
System.out.println("Enter name of first ComputerMicrobe");
name = stdIn.next();
System.out.println("Enter DNA Code for first ComputerMicrobe");
dNACode = stdIn.next();
a = new ComputerMicrobe(name, dNACode);
System.out.println("Enter name of second ComputerMicrobe");
name = stdIn.next();
System.out.println("Enter DNA Code for second ComputerMicrobe");
dNACode = stdIn.next();
b = new ComputerMicrobe(name, dNACode);
System.out.println("Initial set of ComputerMicrobes");
System.out.println(a);
System.out.println(b);
System.out.println("ComputerMicrobe a after mutation");
a.mutate();
System.out.println(a);
System.out.println("ComputerMicrobe b after swap");
b.swap();
System.out.println(b);
System.out.println("ComputerMicrobe c after reproduction of a and b");
c = a.reproduce(b);
System.out.println(c);
System.out.println("ComputerMicrobe b after mutation and swap");
b.mutate().swap();
System.out.println(b);
System.out.println("ComputerMicrobe b after invasion of swap a");
b.invadedBy(a.swap());
System.out.println(b);
} // end main
This demonstration driver does not call all accessor and mutator methods but it is normal to create them regardless of an immediate use. They may be needed in the future. Sample output is provided below. Be sure to be able to reproduce it.
30%
ComputerMicrobe.java
Write a ComputerMicrobe class inside the ComputerMicrobe.java file. This class describe a fictitious Computer Microbe that contains two String attributes: name and dNACode. This class will implement the following methods:
· Accessor (get) and Mutator (set) methods for all its attributes.
· Default constructor and an Alternate Constructor with parameters for all its attributes.
· toString - This method will take no parameters. It will return a new String made out of the dNACode of "this" ComputerMicrobe inside curly brackets ({ }), followed by its name.
· mutate - This method will take no parameters. It will select the middle character on the dNACode and replace it with the character ‘Z'. If the original length of the dNACode is zero or 1, the new DNACode becomes only ‘Z'. The method will return the current object (return this).
· swap - This method will take no parameters. It will swap the first and last characters in the dNACode of an object. For example if the dNACode is "ABCDE", after this method the dNACode will be "EBCDA". Calling the method twice will return to dNACode to its original values. If the length of the dNACode is less than 2, the method will do not modify anything. The method will return the current object (return this).
· reproduce - This method takes another ComputerMicrobe as a parameter and creates a new ComputerMicrobe. This new ComputerMicrobe will have a name that is the concatenation of the first character in the name of the other ComputerMicrobe followed by the first character of the name of "this" ComputerMicrobe. The dNACode of the new ComputerMicrobe will take the first half of the dNACode of the other microbe and concatenate it with the last half of the dNACode of "this" ComputerMicrobe. The method will return the newly created ComputerMicrobe.
· invadedBy - This method takes another ComputerMicrobe as a parameter. The dNACode of the current object (this) will be complete replaced by the reverse dNACode of the ComputerMicrobe from the parameter. For example if the dNACode of the other ComputerMicrobe is "12345", after this method the dNACode of "this" ComputerMicrobe will be "54321". The method will return the current object (return this).
Do not use Arrays or any other advanced concept that was not reviewed in the class to solve this assignment. Assignments that use these concepts will only be graded 10% for presentation.
Sample
Enter name of first ComputerMicrobe
ABCDE
Enter DNA Code for first ComputerMicrobe
12345
Enter name of second ComputerMicrobe
VWXYZ
Enter DNA Code for second ComputerMicrobe
67890
Initial set of ComputerMicrobes
{12345} ABCDE
{67890} VWXYZ
ComputerMicrobe a after mutation
{12Z45} ABCDE
ComputerMicrobe b after swap
{07896} VWXYZ
ComputerMicrobe c after reproduction of a and b
{07Z45} VA
ComputerMicrobe b after mutation and swap
{67Z90} VWXYZ
ComputerMicrobe b after invasion of swap a
{14Z25} VWXYZ

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: You must create two java files one is called
Reference No:- TGS02374346

Now Priced at $15 (50% Discount)

Recommended (94%)

Rated (4.6/5)