Write a driver class that uses the computermicrobe class

Assignment Help JAVA Programming
Reference no: EM131578802

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

 

Reference no: EM131578802

Questions Cloud

How to get the value of totalguesses : how to get the value of "totalGuesses" and "bestGame" in the report value. I think there should be a return method but I did not know how to do that.
Information technology professional prepared : 1. Are information technology professional prepared to be change agents? Should they be?
Implement community behavioral change : How can individual, group, and social efforts be combined to implement community behavioral change?
What is the probability that ith item is the first collision : When we hash n items into k locations, what is the probability that all n items hash to different locations?
Write a driver class that uses the computermicrobe class : You must create two Java files. One is called LastNameFirstNameWeek7Prog.java, and the other is called ComputerMicrobe.java.
Provide health promotion and education : Find a program which was developed to provide health promotion and education to a specific population.
Expected number of kinds of candy chosen by no child : Again as in the previous exercise, we have c children choosing from among ample supplies of d different kinds of candy, one package for each child.
Discuss the similarities between direct and indirect methods : Discuss the similarities and differences between the direct and indirect methods, and the advantages of using each method.
Practice provides performance benefits : Comment on the accuracy of their specification of the conditions under which the practice provides performance benefits

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd