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
elena-14-01-66 [18.8K]
3 years ago
9

Create a class called Hokeemon that can be used as a template to create magical creatures called Hokeeemons. Hokeemons can be of

four types, Dwarf, Elf, Hobbit and Fairy. A dwarf lives in the Mountain, an elf lives in the Dale, a fairy lives in the Forest and a hobbit lives in the Shire. Hokeemons of the same types are always friends. Also, dwarves and elves are friends, and hobbits and fairies are friends.
Computers and Technology
1 answer:
Viefleur [7K]3 years ago
3 0

Answer:

See Explaination

Explanation:

/*****************************************Hokeemon.java********************************/

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class Hokeemon {

private String name;

private String type;

private int age;

public Hokeemon(String name, String type, int age) {

super();

this.name = name;

this.type = type;

this.age = age;

}

public Hokeemon() {

this.name = "";

this.type = "";

this.age = 0;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getType() {

return type;

}

public void setType(String type) {

this.type = type;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public String liveIn() {

if (this.type.equalsIgnoreCase("dwarf")) {

return "Mountain";

} else if (this.type.equalsIgnoreCase("elf")) {

return "Dale";

} else if (this.type.equalsIgnoreCase("fairy")) {

return "Forest";

} else {

return "Shire";

}

}

public boolean areFriends(Hokeemon other) {

if (this.type.equalsIgnoreCase(other.type)) {

return true;

} else if ((this.type.equalsIgnoreCase("dwarf") && other.type.equalsIgnoreCase("elf"))

|| (this.type.equalsIgnoreCase("elf") && other.type.equalsIgnoreCase("dwarf"))) {

return true;

} else if ((this.type.equalsIgnoreCase("hobbit") && other.type.equalsIgnoreCase("fairy"))

|| (this.type.equalsIgnoreCase("fairy") && other.type.equalsIgnoreCase("hobbit"))) {

return true;

} else {

return false;

}

}

public static Hokeemon[] getData(String file) {

Hokeemon[] hokeemons = new Hokeemon[8];

int i = 0;

try {

Scanner scan = new Scanner(new File(file));

while (scan.hasNextLine() && i < hokeemons.length) {

String line = scan.nextLine();

String[] data = line.split("\\s+");

String name = data[0];

String type = data[1];

int age = Integer.parseInt(data[2]);

hokeemons[i] = new Hokeemon(name, type, age);

i++;

}

scan.close();

} catch (FileNotFoundException e) {

System.err.println(e);

}

return hokeemons;

}

public static String getBio(Hokeemon[] hokeemons) {

String s = "";

for (Hokeemon hokeemon : hokeemons) {

s += "I am " + hokeemon.getName() + ": Type " + hokeemon.getType() + ": Age=" + hokeemon.getAge()

+ ", I live in " + hokeemon.liveIn() + "\n";

s += "My friends are: ";

for (Hokeemon hokeemon2 : hokeemons) {

if (hokeemon.areFriends(hokeemon2) && !hokeemon.equals(hokeemon2)) {

s += (hokeemon2.getName() + " ");

}

}

s += "\n";

}

return s;

}

atOverride

public String toString() {

return "Name " + name + ": Type " + type + ": Age=" + age + "\n";

}

}

/*******************************HokeemonMain.java**************************/

import java.util.Arrays;

public class HokeemonMain {

public static void main(String[] args) {

Hokeemon[] hokeemons = Hokeemon.getData("data.txt");

System.out.println(Arrays.toString(hokeemons));

System.out.println(Hokeemon.getBio(hokeemons));

}

}

/**********************************data.txt********************/

Noddy Dwarf 4

Legolas Elf 77

Minerva Fairy 33

Samwise Hobbit 24

Merry Hobbit 29

Warhammer Dwarf 87

Ernedyll Elf 19

Frodo Hobbit 18

You might be interested in
The default _____ color is set when you type text.
Elenna [48]
The default hyperlink color is automatically set when you type
5 0
2 years ago
How to connect canon printer to computer?
denpristay [2]
<span>Step 1Determine what type of connection you need for your computer and printer. If you see a large rectangular connection on your printer it is a parallel printer, and you will need to make sure you have a parallel port on your computer. This connection will be long and rectangular, and it may be red in color. If your Canon printer has a small square connection on the back it is a USB printer, and you will need to look for a flat slot on your computer to hook it up.Step 2Connect the printer and computer. If you are working with a parallel printer connect the large end of the cable to the back of the printer and the smaller end to the computer. If you have a USB printer, connect the square end of the cable to the back of the printer and the flat end to a free USB port on your computer.Step 3Turn on your printer and the computer. Insert the print cartridges that come with the printer. Watch the lower right-hand corner of your computer screen for a "found new hardware" message. This is your indication that the operating system has found your new printer and is installing the proper driver for it.Step 4Insert the CD that comes with your printer, if you are prompted to do so. If your operating system was unable to find a suitable driver it will prompt you for the CD. Keep your CD handy anyway, because you will need it to install the printer utilities.Step 5Insert the CD and allow it to install your printer utilities. After the utilities are installed you will be prompted to clean and align the print heads on your new printer. After the print heads have been aligned your new Canon printer will be ready for use.hope this helps</span>
7 0
2 years ago
You work as the IT administrator for a small business and are responsible for the corporate network. Until now, the network has
posledela

Answer:

Extend a Volume:

1. in the lower left-hand corner, R click the start page thumbnail and select disk management

2. if needed, click ok to initialize any new disks.

3. R click the volume and select extend volume.

4. click next.

5. for the system volume, you can only extend the volume onto the existing disk. type the amount of disk space to add to the volume and click next. click finish.

Convert a Disk to Dynamic

1. In Disk management, R click the disk and select convert to Dynamic Disk

2. Select the disk to convert, click ok.

3. Click convert

4. If the disk contains a volume, you will be shown a warning message. Click Yes to continue.

Create a Spanned Volume

1. In disk management, R click a disk or free space on a disk and select New Spanned Volume.

2. Click Next

3. Select the disks that will be part of the spanned volume and click Add. You must select at least 2 disks to create a spanned volume.

4. To modify the amount of space used on a disk for the new volume, select the disk in the right box, and then edit the number in the select the amount of space in MB: field.

5. Click next

6. Select the drive letter and click Next

7. Type the volume label, then click next

8. Click finish

9. If the new volume includes a space from a disk that is currently a basic disk, you will be prompted to convert the disk to a dynamic disk. Click Yes to create the volume.

Explanation:

5 0
3 years ago
Why is a positive attitude towards work important
bezimeni [28]

Answer:

it lets you get more work done

Explanation:

when you have a positive work attitude you want to do more stuff, and when it's bad you won't want to do anything

3 0
2 years ago
What is a router?
DIA [1.3K]

Answer:

A) a device that sends data to the receiving device

Explanation:

3 0
3 years ago
Other questions:
  • An IT technician has manually configured an IP address on a laptop for a new employee. Each time the employee tries to connect t
    8·1 answer
  • Write a program that prints the block letter “B” in a 7x7 grid of stars like this:
    13·1 answer
  • Which subject area describes collecting and analyzing data from computer systems, networks, and storage devices, as part of an i
    7·1 answer
  • 2.8 Code Practice: Question 1
    7·2 answers
  • A properYour customer has connected a 1000-watt microwave oven and a 600-watt mixer to a 15-amp branch service line for the kitc
    11·2 answers
  • How do you find the exterior angle measure of any regular polygon? (The degree in which to turn the turtle to draw a shape)
    10·1 answer
  • To view paragraph marks, click on the ______ tab, in the paragraph group, click show/hide
    11·1 answer
  • A digital certificate system: Group of answer choices uses digital signatures to validate a user's identity. is used primarily b
    13·1 answer
  • Solve the recurrence relation.<br> S(1)=1<br> S(n)= S(n-1)+(2n-1) for n&gt;=2
    13·1 answer
  • HELPPPP KOKICHI IS OUT TO KILL ME
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!