Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

COS 161 – Algorithms in Programming Project 03 – Truth Spotter Objectives The objective of this assignment is to become familiar with using ArrayLists and Interfaces. General Instructions for all...

1 answer below »
COS 161 – Algorithms in Programming
Project 03 – Truth Spotte
Objectives
The objective of this assignment is to become familiar with using
A
ayLists and Interfaces.
General Instructions for all Assignments
For each assignment you will write a Java program and test it. Start your
programs with a comment block such as:
/*
NAME:
COS 161, Summer 2020, Prof.
Project ##
File Name: CLASS_NAME.java
*
Your programs should be neatly formatted, and follow the indenting,
formatting, spacing, and commenting practices taught in class.
Read each assignment carefully to see what is required. If you do not
understand something in the assignment, ask a tutor or the instructor. You
will get partial credit if you finish only part of an assignment or it is
not working co
ectly. Turn it in and explain what you completed and what
issues it has. It is usually better to turn in an imperfect assignment on
the due date, rather than falling behind in the course.
Part 1 (15 points) Create Classes
The purpose of this assignment is to recreate the Lie Swatter™ game from
the JackBox Party Pack™. The game allows for multiple players to
participate, determining if they think a statement is true or false. The
game keeps score for each player and progresses through multiple rounds
efore displaying who is the winner. If you are not familiar with the game
(we played in class, so check the recording for that if you weren’t
present), you can find more information at the following link:
https:
jackboxgames.fandom.com/wiki/Lie_Swatter
https:
jackboxgames.fandom.com/wiki/Lie_Swatte
Note: this application should run in the console, no graphical user
interface is required. Adding a DrawingPanel output is the extra credit
for this assignment, it is highly recommended that you do not implement
the graphical display until you have completed everything else.
To begin, create two classes called Statement and Player, respectively.
• In the Statement class, include 2 private Strings one called claim, and
the other called explanation. Also include a private boolean value
isTrue. Create accessors and mutators for these fields (getters and
setters).
• In the Player class, include a private String field called name. Also
create a private int field named score. Create accessors and mutators
for these fields (getters and setters). Implement the
Comparable interface. The compareTo method should compare
players based on scores.
These classes will serve as the main classes you interact with as you
uild the game. You will want (and must) add to them as you go, but make
sure you do not remove any of these fields, accessors, or mutators.
You can add constructors to these classes if you want, or just use the
default constructor.
Part 2 (15 Points) Read Files and Create Your Own Category
First, create an A
ayList for each of the categories. The A
ayLists
should store Statement objects.
Add the supplied files into your Eclipse project and declare a method
called readFiles(String[] fileNames). This method will take in a
ay of
Strings which contain the names of the files (Entertainment.txt, Food.txt,
History.txt, World.txt). For each fileName, the method should read the
file using a scanner, creating a new Statement object, and adding that
object to the co
esponding A
ayList.
Once this is working, create your own category file and populate it with
information (this can be anything you like, just make sure it has at least
10 statements). Modify the code you have with another A
ayList for this
new category, and make sure you modify the call to readFiles() so it now
eads your file as well.
Part 3 (15 Points) Take in Player Count and Names
Take in from the console the number of players. You must limit the number
of players to be between 2 and 8 for our implementation. You must also
allow each player to enter in their name. At this point, you must create a
way to track what each player uses to indicate whether a statement is true
or false. I would recommend doing the following, but if you would prefer
to do it another way, and it makes sense to you, this is not required.
• Add 2 char fields to the Player class, one called trueChar and the
other called falseChar.
• When a player enters their name, assign and display to them a random
keyboard character for true, and one for false that they will enter
to indicate their guess (this allows multiple people around a
keyboard to play, as they won’t know what other players keys are)
• Make sure you display this to each player so they know what to enter,
and also make sure you do not accidently reuse a character between
two players (creating an A
ayList of chars with the alphabet and
.remove() are helpful for this).
• Add a char field to the Player class named cu
entGuess, this will be
useful later and will be set and erased every round. This could also
e a boolean, but you will have to do some calculations to set it
ased on what the trueChar and falseChar are.
Part 4 (35 Points) Run the Game
Create a method called runGame() that randomly selects 3 of your
categories (one for each round), then shuffles the A
ayLists containing
those category (this will change up the order so the same questions aren’t
in the same order every time). Once the A
ayList is shuffled, display a
question, and take in user input from the players. My recommendation for
how to do this is to create a method that does the following:
• Read a single char from the console, allowing one player to enter their
true or false guess. Use this char to find the co
ect player (since
char values are not repeated this should be simple enough), then set
this char as that players cu
entGuess
• Keep taking char input until every player has entered their guess (it
may help to store the number of players somewhere easy to access for
this)
Once you have taken in the user input, determine if there is an
“explanation” in the statement and print it if there is. Then, compare the
player guesses to the co
ect answer from the Statement and allocate score
appropriately. After 5 questions, a round is over. Sort the A
ayList of
Players (compareTo() should do this based on score), and display the
cu
ent scores. Then move on to the next chosen category.
Once three rounds are done, display the final scores and give the players
the opportunity to play again (with same or different players). Make sure
you reset anything necessary to the default. This is much easier if you
make methods for the setup instead of doing everything in main.
Extra Credit (10 points) Add a GUI
Go back and add a graphical user interface display to the game. It can
look like what the actual game looks like, or you can create one of your
own. It can be simple or complex, but must display the statements, the
esults, and the scores of the players.
Extra Credit (10 Points) Extra Time Features
Look into the Java Timer class
(https:
docs.oracle.com/javase/8/docs/api/javax/swing/Timer.html) Add the
InputTimer.java file into your project, and modify your code to only take
user input within a certain interval (while a certain value is true). Any
user who does not put in input by the time the time expires gets no
points, so make sure cu
entGuess is wiped out beforehand. The following
code should help with this.
https:
docs.oracle.com/javase/8/docs/api/javax/swing/Timer.html
What to Turn In
Turn in your program(s) and their output(s) as a single pdf file. When you
cut and paste your code or output into a word processor it may look
distorted if it uses a non-fixed width font. If that happens, select your
pasted text, and change the font into a fixed width font such as Courier.
It is your responsibility to make your code and output neat and readable.
If you have trouble converting a word processor document into a pdf, ask
the instructor for assistance.
Once you have the single document ready, submit it as an attachment on
Blackboard.
**NOTE: FOR THIS AND FUTURE ASSIGNMENTS, PLEASE ALSO ATTACH ALL YOUR .JAVA
AND ANY OTHER FILES YOU ADDED TO THE BLACKBOARD SUBMISSION.

Create the Timer object which is necessary to call a TimerTask
Timer timer = new Timer();

Make the InputTImer that we will use the isRunning from
InputTimer inputTask = new InputTimer();

Schedule the Task with a delay

the int value to change how long it waits in milliseconds
timer.schedule(inputTask, 250);
while (inputTask.isRunning) {
XXXXXXXXXXSystem.out.println("Still Running!!");
}
System.out.println("Finished!!!!!!!!");

A
aham Lincoln had no middle name.
true
Ronald Reagan was a waiter during high school.
false
He was a lifeguard.
Broccoli was once banned from the White House.
true
In 1990, George H.W. Bush claimed
occoli would no longer be in the White House.
Before becoming queen, Queen Elizabeth was a mechanic.
true
The Boston Red Sox finally won a World Series in 2016.
true
The Chicago Cubs won the series after 108 years.
The first Olympic games honored Alexander the Great.
false
They honored Zeus, the king of the Greek gods.
United States postage stamps may only honor people who are dead.
false
In 2011,that rule was overturned.
Barack Obama's favorite app is Candy Crush Saga.
false
In an interview with Ba
ara Walters, Barack Obama said his favorite app is Scra
le.
Albert Einstein was awarded the Nobel Prize in Physics.
true
Gone with the Wind takes place in Savannah, Georgia.
false
The American Civil War ended in 1776.
false
Answered Same Day Jul 28, 2021

Solution

Arun Shankar answered on Jul 30 2021
153 Votes
Project_03
in/mathematics.txt
2 is the only even prime number.
true
All other even numbers are divisible by 2.
23482347 is a perfect square.
false
A perfect square cannot have 7 as its unit's digit.
Natural numbers are well ordered.
true
0 is the least element.
Integers are well ordered.
false
There is no integer that is strictly lesser than all other integers.
f(x) = |x| is a continuous function.
true
f(x) = |x| is a differentiable function.
false
The function is not derivable at x = 0.
If a and b are both prime, they are coprime.
true
The only factors of a are 1 and a, and the only factors of b are 1 and b. So the only common factor is 1.
If a and b are coprime, and b and c are coprime, then a and c are coprime.
false
2 and 5 are coprime, 5 and 6 are coprime, but 2 and 6 are not coprime.
8723 is divisible by 3.
false
Sum of digits = 20 is not divisible by 3.
There are as many natural numbers as there are even natural numbers.
true
f(n) = 2n is a bijection.
Project_03
in/entertainment.txt
The kids' bathroom on The Brady Bunch didn't have a toilet.
true
Nemo is a puffer fish.
false
He is a clown fish.
There was no World Series in 1994.
true
Baseball players were on strike that year.
John Lennon's middle name was Edward.
false
His middle name was Winston.
Pinocchio was the first animated, full-color Walt Disney feature film.
false
It was Snow White and the Seven Dwarfs.
In the Star Wars franchise movies, the voice of Yoda is played by the same person who did the voices of Miss Piggy, Grover, and Cookie Monster.
truef
The voices were performed by FrankOz
All the kings in a standard deck of cards have a mustache.
false
The King of Hearts does not have a mustache.
Mario of Super Mario Bros. fame was once a carpente
true
He was first introduced as a carpenter in the videogame, DonkeyKong.
The name of Batman's butler is Albert
false
The butler's name is Alfred
Mayim Bialik, who plays Amy Fa
ah Fowler on the Big Bang Theory,is a neuroscientist.
true
She earned her Ph.D.in neuroscience in 2007.
Donald Duck's sister is named Donna.
false
Her name is Dumbella.
Elvis Presley had a twin
othe
true
His twin died at birth.
In the famous commercial, Jake from State Farm was wearing jeans.
false
He was wearing khakis.
Johnny Depp is afraid of spiders.
false
He's afraid of clowns.
The first name of Kramer in Seinfeld is Cosmo.
true
Project_03
in/world.txt
Japan has square watermelons.
true
Porcupines can float.
true
There are 100 dimples on a golf ball.
false
Per the Department of Physics at the University of Illinois at U
ana-Champaign, there are between 300 and 500 dimples.
Cows sleep standing up.
true
Polar bears' skin is black.
true
Alabama is the state printed on a Jack Daniel's label.
false
It's Tennessee.
Lightning never strikes the same place twice.
false
Lightning can strike anywhere more than once.
Fortune cookies were invented in China.
false
They were invented in the United States.
Dalmatians are born with black spots.
false
They're born with a white coat and usually develop spots around three weeks old.
It's illegal in Georgia to eat fried chicken with a knife and fork.
true
Georgia law says you can only eat fried chicken with your bare hands.
The capital of Libya is Benghazi.
false
Baby koalas are called joeys.
true
Brazil is the only country in the Americas whose official language is Portuguese.
true
Project_03
in/Driver.class
Project_03
in/history.txt
A
aham Lincoln had no middle name.
true
Ronald Reagan was a waiter during high school.
false
He was a lifeguard.
Broccoli was once banned from the White House.
true
In 1990, George H.W. Bush claimed
occoli would no longer be in the White House.
Before becoming queen, Queen Elizabeth was a mechanic.
true
The Boston Red Sox finally won a World Series in 2016.
true
The Chicago Cubs won the series after 108 years.
The first Olympic games honored Alexander the Great.
false
They honored Zeus, the king of the Greek gods.
United States postage stamps may only honor people who are dead.
false
In 2011,that rule was overturned.
Barack Obama's favorite app is Candy Crush Saga.
false
In an interview with Ba
ara Walters, Barack Obama said his favorite app is Scra
le.
Albert Einstein was awarded the Nobel Prize in Physics.
true
Gone with the Wind takes place in Savannah, Georgia.
false
The American Civil War ended in 1776.
false
Project_03
in/Player.class
Project_03
in/food.txt
Germany drinks the most beer in the world per person.
false
The Czech Republic drinks the most beer.
In some states, it's illegal to eat specific foods while walking backwards.
true
You may not eat doughnuts and walk backwards in Marion, Ohio; you may not eat peanuts and walk backwards during a concert in Green, New York, and you may not walk backwards while eating a hamburger in Oklahoma City, Oklahoma.
Twinkies originally had banana filling.
true
The name of the dog on a box of CrackerJack's is Spot.
false
The dog's name is Bingo.
People in Japan eat Kentucky Fried Chicken for Christmas dinner.
true
The first food grown and eaten in space was potatoes
false
The first food...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here