Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
8th Edition
ISBN: 9781337091480
Author: Joyce Farrell
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 3, Problem 2GZ

Explanation of Solution

Program code:

MyCharacter.java

//define a class MyCharacter

public class MyCharacter

{

//define the class member variables

private String name;

private int health;

private int power;

//constructor

public MyCharacter()

{

}

//constructor

public MyCharacter(String n, int h, int p)

{

//initialize the variables

name = n;

health = h;

power = p;

}

//define the method getName()

public String getName()

{

//return the value of name

return name;

}

//define the method setName()

public void setName(String name)

{

//set the value of name

this.name = name;

}

//define the method getHealth()

public int getHealth()

{

//return the value of health

return health;

}

//define the method setHealth()

public void setHealth(int health)

{

//set the value of health

this.health = health;

}

//define the method getPower()

public int getPower()

{

//return the value of power

return power;

}

//define the method setPower()

public void setPower(int power)

{

//set the value of power

this.power = power;

}

}

Explanation:

The above snippet of code is used to create a class “MyCharacter”. In the code,

  • Import the required header files.
  • Define a class “MyCharacter”
    • Declare the class variables “name”, “health” and “power”.
    • Define the constructor “MyCharacter”.
      • Set the values of variables “name”, “health” and “power”.
    • Define the “getName()” method.
      • Return the value of “name”.
    • Define the “setName()” method...

Blurred answer
Students have asked these similar questions
You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, and country. You want to retrieve the first 3 letters of each country name. You decide to use the SUBSTR function to retrieve the first 3 letters of each country name, and use the AS command to store the result in a new column called new_country.  You write the SQL query below. Add a statement to your SQL query that will retrieve the first 3 letters of each country name and store the result in a new column as new_country.
We are considering the RSA encryption scheme. The involved numbers are small, so the communication is insecure.  Alice's public key (n,public_key) is (247,7). A code breaker manages to factories  247 = 13 x 19  Determine Alice's secret key. To solve the problem, you need not use the extended Euclid algorithm, but you may assume that her private key is one of the following numbers 31,35,55,59,77,89.
Consider the following Turing Machine (TM). Does the TM halt if it begins on the empty tape? If it halts, after how many steps? Does the TM halt if it begins on a tape that contains a single letter A followed by blanks? Justify your answer.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning