1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
hammer [34]
3 years ago
10

Public class SomeClass { private String aName; private int aNumber; private boolean amAwesome; public SomeClass(String name, int

number){ aName = name; aNumber = number; amAwesome = true; } public SomeClass(String name, int number, boolean awesome){ aName = name; aNumber = number; amAwesome = awesome; } public void methodAwesome(int number){ if(amAwesome) aNumber += number - 5; amAwesome = !amAwesome; } public int method Fantastic(boolean fantastic){ fantastic = fantastic && amAwesome; if(!fantastic && aNumber > 0) aName = aName + " is fantastic"; return aNumber *= -2; } public void methodAmazing(int num){ if(aNumber < 0) aNumber = num; } public static void main(String[] args) { SomeClass awesome = new SomeClass("Awesome", 5); awesome.methodAmazing(10); int eNum = awesome.method Fantastic(true); SomeClass amazing = new SomeClass("Amazing", -10, false); amazing.methodAwesome(7); amazing.methodAmazing(18); SomeClass fantastic = new SomeClass ("Fantastic", 11, true); int fanNum = fantastic.methodFantastic(true); fantastic.methodAwesome(awNum + fanNum); } }
How many objects are created in the main method
Computers and Technology
1 answer:
scoray [572]3 years ago
3 0

Answer:

The objects created in the main method and their initial states are given below

Explanation:

The objects and initial state of each object( the values of each object’s variables) are thus:

We have objects awesome, amazing and fantastic.

initial state of awesome object is

aName = "Awesome"; aNumber = 5; amAwesome = true;

initial state of amazing object is

aName = "Amazing"; aNumber = -10; amAwesome = false;

initial state of fantastic object is

aName = "Fantastic"; aNumber = 11; amAwesome = true

You might be interested in
Students are studying the effects of beach pollution by counting populations of seagulls at two different beach locations. One l
KIM [24]

Answer:

The number of seagulls in each location.

Explanation:

Dependent variables are something that you are recording or measuring.

7 0
2 years ago
When you need to cut new external threads on a bolt, which of the following tools should you use?
Law Incorporation [45]

when your threading a bolt no specific kind you should use a die

8 0
3 years ago
Read 2 more answers
Which of the following statements should be avoided when developing a mission statement?
Citrus2011 [14]

Answer: The how-to statements

Explanation:

The mission statement is simply a short summary of the purpose of a company. It is the guideline on how a company will operate. The mission statement states the reason for the existence of a company, products sold or service rendered and the company's goals.

The mission statement should be brief but comprehensive, consist of simple words and describe the “who, what, and where” of the organization.

Therefore, the incorrect option based on the explanation above is "The how-to statements". This shouldn't be part of the mission statement.

3 0
3 years ago
Tortise and hare race java g Modify the main class so it runs the race 100 times and reports how many times each runner wins. (T
SOVA2 [1]

Answer:

Game.java file

import java.util.Scanner;

public class Game {

/**

* t_pos and h_pos are the current positions of the Tortoise and Hare

*/

static int t_pos,h_pos;

static Tortoise tortoise;

static Hare hare;

public static void main(String[] args) {

play(); /*starting the game*/

}

public static void play(){

/**

* the method will starts the play, loop until the game is over, displays the winner

* and prompts the user if they want to play again

*/

/**

* defining Tortoise and Hare objects

*/

tortoise=new Tortoise();

hare=new Hare();

t_pos=1;

h_pos=1;

System.out.println("The race is about to start");

tortoise.printTrack();

hare.printTrack();

while(t_pos != 50 && h_pos !=50){

System.out.println("\n\n\n"); /*printing blank lines*/

t_pos=tortoise.move(); /*moving and getting the current position of tortoise*/

h_pos=hare.move();/*moving and getting the current position of hare*/

tortoise.printTrack(); /*displaying the tracks*/

hare.printTrack();

try { /*comment this part to skip the 1s break between each round; for testing*/

Thread.sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}

}

System.out.println("\nRace Over");

if(t_pos==50 && h_pos==50){

System.out.println("Its a tie");

}

else if(t_pos==50){

System.out.println("Tortoise wins");

}else if(h_pos==50){

System.out.println("Hare wins");

}

System.out.println("Do you want to play again? (y/n)");

Scanner scanner=new Scanner(System.in);

String ch=scanner.next();

if(ch.equalsIgnoreCase("y")){

play();

}else if(ch.equalsIgnoreCase("n")){

System.out.println("Thanks for playing, Goodbye");

}else{

System.out.println("Invalid choice, quitting..");

}

}

}

//Tortoise.java

public class Tortoise {

/**

* the current position of the tortoise

*/

int position;

/**

* track array

*/

char[] track;

/**

* speed of tortoise

*/

int speed=1;

public Tortoise() {

position=0;

track=new char[50];

for(int i=0;i<track.length;i++){

/**

* filling the track

*/

track[i]='-';

}

}

public int move(){

if(position<track.length){

position=position+speed;

}

return position+1;

}

public void printTrack(){

/**

* the current position of tortoise will be displayed by 'T' everything else will be '-'

*/

System.out.println();

for(int i=0;i<track.length;i++){

if(i==position){

System.out.print('T');

}else{

System.out.print(track[i]);

}

}

}

}

//Hare.java

import java.util.Random;

public class Hare {

int position;

int speed=10;

char[] track;

/**

* Random object to generate a random number

*/

Random random;

/**

* resting percent denotes how much time Hare will be resting

*/

int resting_percent=90;

public Hare() {

position=0;

track=new char[50];

for(int i=0;i<track.length;i++){

track[i]='-';

}

random=new Random();

}

public int move(){

int n=random.nextInt(100-1)+1; /*generating a random number between 1 and 100*/

if(n<=resting_percent){

/**

* at rest; will not move, returns the current position.

*/

return position;

}else{

/**

* not resting..

*/

if(position<track.length){

if(position+speed>=track.length){

position=track.length-1;

}else{

position=position+speed;

}

}

return position+1;

}

}

public void printTrack(){

System.out.println();

for(int i=0;i<track.length;i++){

if(i==position){

System.out.print('H');

}else{

System.out.print(track[i]);

}

}

}

}

/*Output (partial and random)*/

The race is about to start

T-------------------------------------------------

H-------------------------------------------------

-T------------------------------------------------

H-------------------------------------------------

--T-----------------------------------------------

H-------------------------------------------------

---T----------------------------------------------

----------H---------------------------------------

.

.

.

.

-----------------------------------------------T--

-------------------------------------------------H

Race Over

Hare wins

Do you want to play again? (y/n)

y

The race is about to start

T-------------------------------------------------

H-------------------------------------------------

-T------------------------------------------------

H-------------------------------------------------

.

.

.

.

-----------------------------------------------T--

--------------------H-----------------------------

------------------------------------------------T-

--------------------H-----------------------------

-------------------------------------------------T

--------------------H-----------------------------

Race Over

Tortoise wins

Do you want to play again? (y/n)

n

Explanation:

3 0
3 years ago
NumA = 3 <br>numB = 2<br>Result = numA ** numB
Paul [167]

Answer:

The result of the following code will be 9

Explanation:

There are several operators used in Python to do mathematical calculations.

** operator is used for exponents.

i.e.

a ** b mathematically means a^b

Here in the given code

3 is assigned to numA and 2 is assigned to numB

Result will be equal to 3^2

Hence,

The result of the following code will be 9

3 0
2 years ago
Other questions:
  • April 107 90 29 31 66 0.344
    8·1 answer
  • You are attempting to update a Windows image that has been mounted under C:\mount on your local system. What command must you us
    13·1 answer
  • Which destination ip address is used when an ipv6 host sends a dhcpv6 solicit message to locate a dhcpv6 server?
    15·1 answer
  • In an inheritance situation, the new class that you create from an existing class is known as the:
    5·1 answer
  • How many slides should a presentation include?
    11·2 answers
  • Write a program "addnumbers.c" where it takes as many arguments as the user includes as command line arguments and calculates th
    11·1 answer
  • Which key combination will allow users to move to the top of a document?
    15·1 answer
  • Which componet is the smallest unit in a spreadsheet
    15·1 answer
  • Write a python statement that print the number 1000
    6·1 answer
  • Can someone please explain to me how the points work when you ask a question? Worth 30 points I think, I still don't know how th
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!