Question: Hello, this assignment is about randomness in Javascript, please code this in JAVASCRIPT and a HTML page to display it, thank you. Assignment: The captain

Hello, this assignment is about randomness in Javascript, please code this in JAVASCRIPT and a HTML page to display it, thank you.

Assignment:

The captain has a bottle o' grog to award to the crew mate who can guess his secret number. So, your job is to use constructor notation to create a Pirate object with the properties of rank, favorite number, and html tag id. The object should also have methods that allow the Pirate to choose a random number and speak a phrase. Here, "speaking" means to send the phrase to that pirate's output area. Just to give the crew a fighting chance, the captain should choose an integer between 1 and 10.

Use your Pirate object to instantiate a captain and at least three ship mates. Hmmm... This sounds like a good time to use constructor notation!

The captain should use his speak() method to announce the guessing game to the crew.

Next, the captian will choose a secret number but not tell anyone!

Each crew mate will choose a number and then use his speak() method to output his name, rank, and numeric guess to his own html element. For example, "Sailor Mast Hugger chooses 4. Argh."

After the crew members tell their guesses, the captain uses his speak() method to tell his number.

Any crew member who guesses the captain's secret number wins the prize! If nobody guesses the secret number, the captain gets to keep his bottle o' grog for himself.

Bonus points will be awarded for the captain to announcing the winner of the contest.

Helpful Hint #1: Consider allowing the .speak() method to accept a phrase as a parameter so each pirate can say more than one phrase.

Helpful Hint #2: Choosing a number is an essential function of each pirate, so the pirate's favorite number should NOT be passed as a parameter into the constructor function. A method should choose the number and assign it to the secretNumber property.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!