SlideShare a Scribd company logo
1 of 2
Getting these errors in my code I am getting error that "cannot find symbol WarPlayer." also
getting error: cannot final symbol symbol: method getCardDeck( location: variable deck of type
GroupOfCards
public class WarGame extends Game{ private GroupOfCards deck; final ArrayList warPool =
new ArrayList<>(); private Player Player1; private Player Computer; final int cardsInDeck = 52;
private Player GameWinner = null; public WarGame() { super("War"); } /** * Creates an
ArrayList using the player controlled object and the computer controlled object. * This method
ensures that the game is limited to 1 player and 1 computer. * * @param user */ public void
createPlayerList(Player user) { Player computer = new WarPlayer("Computer"); ArrayList
playerList = new ArrayList(); playerList.add(user); this.Player1 = user;
playerList.add(computer); this.Computer = computer; setPlayers(playerList); } @Override
public void play() { System.out.println(""); System.out.println("Starting game!"); // Instantiate
GroupOfCards to create deck made up of 52 cards deck = new GroupOfCards(cardsInDeck); //
Populates the deck of cards, 4 suits and 13 cards for each suit for (int r = 1; r < 14; r++) { for (int
c = 0; c < 4; c++) { deck.getCardDeck().add(new Card(r, Card.suits[c])); } } // Call shuffle
method from GroupOfCards and shuffle deck deck.shuffle(); System.out.println("Deck built and
shuffled!"); // Create 2 ArrayList's based on the shuffled cards in the deck (one for the user, one
for the computer) ArrayList userCards = new ArrayList<>(); ArrayList computerCards = new
ArrayList<>(); // Even cards are added to user ArrayList, odd cards are added to computer
ArrayList for (int i = 0; i < deck.getCardDeck().size(); i++) { if (i % 2 == 0) {
userCards.add(deck.getCardDeck().get(i)); } else {
computerCards.add(deck.getCardDeck().get(i)); } } // Create 2 GroupOfCards deck objects using
the size of the 2 ArrayLists GroupOfCards playerDeck = new GroupOfCards(userCards.size());
GroupOfCards computerDeck = new GroupOfCards(computerCards.size()); // Set the cards in
these GroupOfCards objects to the ones that were placed in the 2 ArrayLists earlier
playerDeck.setCardDeck(userCards); computerDeck.setCardDeck(computerCards); // Give the 2
GroupsOfCards to the player objects Player1.setCards(playerDeck);
Computer.setCards(computerDeck); // Clear the userCards ArrayList and the computerCards
ArrayList to be used as each players discard pile userCards.clear(); computerCards.clear();
System.out.println("Deck split and distributed!"); System.out.println(""); // Draw the top card in
each players deck int index = 0; boolean runGame = true; while (runGame) { // When a player
runs out of cards, the game ends if (Player1.getCards().getSize() == 0 ||
Computer.getCards().getSize() == 0) { runGame = false; break; } System.out.println("Drawing
cards!"); // Draws top card of both players decks Card playerTopCard =
Player1.getCards().getTopCard(); System.out.println(Player1.getName() + " drew: " +
playerTopCard.toString()); Card computerTopCard = Computer.getCards().getTopCard();
System.out.println(Computer.getName() + " drew: " + computerTopCard.toString());
System.out.println(""); //Compares the 2 cards that were drawn System.out.println("Comparing
cards!"); Player roundWinner = compareCards(playerTopCard, computerTopCard); if
(roundWinner == Player1) { System.out.println(Player1.getName() + " wins the hand!");
userCards.add(playerTopCard); userCards.add(computerTopCard); } else if (roundWinner ==
Computer) { System.out.println(Computer.getName() + " wins the hand!");
computerCards.add(playerTopCard); computerCards.add(computerTopCard); } else {
System.out.println("Stalemate! Cards added to pot."); System.out.println("");
warPool.add(playerTopCard); warPool.add(computerTopCard); startWar(userCards,
computerCards); } System.out.println(""); index++; } if (userCards.size() >
computerCards.size()) { GameWinner = Player1; } else if (userCards.size() <
computerCards.size()) { GameWinner = Computer; } } public Player compareCards(Card
playerCard, Card computerCard) { // Holds the value of each card in a variable so that it can be
referenced quickly int playerCardValue = playerCard.getCardNum(); int computerCardValue =
computerCard.getCardNum(); // Checks if the value of the cards are equal if (playerCardValue
!= computerCardValue) { // if they are not equal, the winner will be the player with the higher
value card if (playerCardValue > computerCardValue) { return Player1; } else { return
Computer; } // if they are equal, the players go to war } else { return null; } } public void
startWar(ArrayList userCard, ArrayList computerCard) { System.out.println("War has broken
out! Each player draws 4 cards."); if (Player1.getCards().getSize() > 3 &&
Computer.getCards().getSize() > 3) { int war = 3; // 3 Cards into the pool for (int i = 0; i < war;
i++) { warPool.add(Player1.getCards().getTopCard());
warPool.add(Computer.getCards().getTopCard()); } } Card playerFinalCard =
Player1.getCards().getTopCard(); System.out.println(Player1.getName() + "'s top card is: " +
playerFinalCard.toString()); Card computerFinalCard = Computer.getCards().getTopCard();
System.out.println(Computer.getName() + "'s top card is: " + computerFinalCard.toString());
warPool.add(playerFinalCard); warPool.add(computerFinalCard); System.out.println(""); Player
warWinner = compareCards(playerFinalCard, computerFinalCard); if (warWinner == Player1) {
System.out.println(Player1.getName() + " wins the war! Pot goes to winner!");
userCard.addAll(warPool); warPool.clear(); } else if (warWinner == Computer) {
System.out.println(Computer.getName() + " wins the war! Pot goes to winner!");
computerCard.addAll(warPool); warPool.clear(); } else { System.out.println("Stalemate! A new
war will soon breakout..."); startWar(userCard, computerCard); } System.out.println(""); }
@Override public void declareWinner() { if (GameWinner == null) { System.out.println("No
winner!"); } else if (GameWinner == Player1) { System.out.println("Winner is Player 1."); } else
if (GameWinner == Computer) { System.out.println("Winner is Computer."); } } } getting error
Player computer = new WarPlayer("Computer");

More Related Content

Similar to Getting these errors in my code I am getting error that -cannot find.docx

FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdf
abifancystore
 
เกมจับคู่1
เกมจับคู่1เกมจับคู่1
เกมจับคู่1
JAy YourJust'one
 
Introduction Now that the Card and Deck classes are completed, th.pdf
Introduction Now that the Card and Deck classes are completed, th.pdfIntroduction Now that the Card and Deck classes are completed, th.pdf
Introduction Now that the Card and Deck classes are completed, th.pdf
charanjit1717
 
Thanks so much for your help. Review the GameService class. Noti.pdf
Thanks so much for your help. Review the GameService class. Noti.pdfThanks so much for your help. Review the GameService class. Noti.pdf
Thanks so much for your help. Review the GameService class. Noti.pdf
adwitanokiastore
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
anjandavid
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
aoneonlinestore1
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
ezzi97
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Here is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdfHere is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdf
anithareadymade
 
Construct a java method.   This method chooses the number of sti.pdf
Construct a java method.    This method chooses the number of sti.pdfConstruct a java method.    This method chooses the number of sti.pdf
Construct a java method.   This method chooses the number of sti.pdf
arihantmobilepoint15
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
manjan6
 

Similar to Getting these errors in my code I am getting error that -cannot find.docx (17)

FaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdfFaceUp card game In this assignment we will implement a made.pdf
FaceUp card game In this assignment we will implement a made.pdf
 
Save game function
Save game functionSave game function
Save game function
 
เกมจับคู่1
เกมจับคู่1เกมจับคู่1
เกมจับคู่1
 
Introduction Now that the Card and Deck classes are completed, th.pdf
Introduction Now that the Card and Deck classes are completed, th.pdfIntroduction Now that the Card and Deck classes are completed, th.pdf
Introduction Now that the Card and Deck classes are completed, th.pdf
 
Thanks so much for your help. Review the GameService class. Noti.pdf
Thanks so much for your help. Review the GameService class. Noti.pdfThanks so much for your help. Review the GameService class. Noti.pdf
Thanks so much for your help. Review the GameService class. Noti.pdf
 
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
Games, AI, and Research - Part 2 Training (FightingICE AI Programming)
 
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdfIn Java using Eclipse, Im suppose to write a class that encapsulat.pdf
In Java using Eclipse, Im suppose to write a class that encapsulat.pdf
 
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdfimport java.awt.;import java.awt.event.;import javax.swing.;.pdf
import java.awt.;import java.awt.event.;import javax.swing.;.pdf
 
C++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdfC++You will design a program to play a simplified version of war, .pdf
C++You will design a program to play a simplified version of war, .pdf
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Create the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdfCreate the variables, and methods needed for this classA DicePlay.pdf
Create the variables, and methods needed for this classA DicePlay.pdf
 
Here is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdfHere is the code for youimport java.util.Scanner; import java.u.pdf
Here is the code for youimport java.util.Scanner; import java.u.pdf
 
The Ring programming language version 1.4.1 book - Part 19 of 31
The Ring programming language version 1.4.1 book - Part 19 of 31The Ring programming language version 1.4.1 book - Part 19 of 31
The Ring programming language version 1.4.1 book - Part 19 of 31
 
Construct a java method.   This method chooses the number of sti.pdf
Construct a java method.    This method chooses the number of sti.pdfConstruct a java method.    This method chooses the number of sti.pdf
Construct a java method.   This method chooses the number of sti.pdf
 
Please help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdfPlease help with this. program must be written in C# .. All of the g.pdf
Please help with this. program must be written in C# .. All of the g.pdf
 
Code em Poker
Code em PokerCode em Poker
Code em Poker
 
AI For Texam Hold'em poker
AI For Texam Hold'em pokerAI For Texam Hold'em poker
AI For Texam Hold'em poker
 

More from LeonardN9WWelchw

Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docxGranite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
LeonardN9WWelchw
 
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docxGraded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
LeonardN9WWelchw
 
Governmental population policies 39- True-false- Today- almost every s.docx
Governmental population policies 39- True-false- Today- almost every s.docxGovernmental population policies 39- True-false- Today- almost every s.docx
Governmental population policies 39- True-false- Today- almost every s.docx
LeonardN9WWelchw
 
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docx
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docxGovernment Employs Backdoor Searches ACSB standards- Social and Ethica.docx
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docx
LeonardN9WWelchw
 

More from LeonardN9WWelchw (20)

Choose the scenario that uses social engineering- 1- Bob pretends t.docx
Choose the scenario that uses social engineering-    1- Bob pretends t.docxChoose the scenario that uses social engineering-    1- Bob pretends t.docx
Choose the scenario that uses social engineering- 1- Bob pretends t.docx
 
Ciastion- Bextint- Hand to tovinitroct- Guarution 7pirect n Requiremen.docx
Ciastion- Bextint- Hand to tovinitroct- Guarution 7pirect n Requiremen.docxCiastion- Bextint- Hand to tovinitroct- Guarution 7pirect n Requiremen.docx
Ciastion- Bextint- Hand to tovinitroct- Guarution 7pirect n Requiremen.docx
 
Choose the correct statement- A- A chartered bank is a private firm- c.docx
Choose the correct statement- A- A chartered bank is a private firm- c.docxChoose the correct statement- A- A chartered bank is a private firm- c.docx
Choose the correct statement- A- A chartered bank is a private firm- c.docx
 
ClearView Investment Company reported the following data retrieved fro.docx
ClearView Investment Company reported the following data retrieved fro.docxClearView Investment Company reported the following data retrieved fro.docx
ClearView Investment Company reported the following data retrieved fro.docx
 
choose a country (not Canada- and not your home country) and create a.docx
choose a country (not Canada- and not your home country) and create a.docxchoose a country (not Canada- and not your home country) and create a.docx
choose a country (not Canada- and not your home country) and create a.docx
 
Cindy Nelson is a real estate property manager who has just quit her p.docx
Cindy Nelson is a real estate property manager who has just quit her p.docxCindy Nelson is a real estate property manager who has just quit her p.docx
Cindy Nelson is a real estate property manager who has just quit her p.docx
 
choose the correct answer- choose the correct answer- financia instrum.docx
choose the correct answer- choose the correct answer- financia instrum.docxchoose the correct answer- choose the correct answer- financia instrum.docx
choose the correct answer- choose the correct answer- financia instrum.docx
 
choose 4 national culture dimensions from the list and explain what th.docx
choose 4 national culture dimensions from the list and explain what th.docxchoose 4 national culture dimensions from the list and explain what th.docx
choose 4 national culture dimensions from the list and explain what th.docx
 
Choose 3 things that are true for this diagram- Left side is hypotonic.docx
Choose 3 things that are true for this diagram- Left side is hypotonic.docxChoose 3 things that are true for this diagram- Left side is hypotonic.docx
Choose 3 things that are true for this diagram- Left side is hypotonic.docx
 
Choices to match with above- temperate grasslands coral reef Ocean tem.docx
Choices to match with above- temperate grasslands coral reef Ocean tem.docxChoices to match with above- temperate grasslands coral reef Ocean tem.docx
Choices to match with above- temperate grasslands coral reef Ocean tem.docx
 
h G- Give adjacency list representation- 7 8.docx
h G- Give adjacency list representation- 7 8.docxh G- Give adjacency list representation- 7 8.docx
h G- Give adjacency list representation- 7 8.docx
 
Habitable features of exoplanets On the habitable planet (left)- plate.docx
Habitable features of exoplanets On the habitable planet (left)- plate.docxHabitable features of exoplanets On the habitable planet (left)- plate.docx
Habitable features of exoplanets On the habitable planet (left)- plate.docx
 
Guide Week 03a First Natural Philosophers Spring 2023-d dy Guide Week.docx
Guide Week 03a First Natural Philosophers Spring 2023-d dy Guide Week.docxGuide Week 03a First Natural Philosophers Spring 2023-d dy Guide Week.docx
Guide Week 03a First Natural Philosophers Spring 2023-d dy Guide Week.docx
 
gueltion 16 A social injustice is a situation where b- equity is appli.docx
gueltion 16 A social injustice is a situation where b- equity is appli.docxgueltion 16 A social injustice is a situation where b- equity is appli.docx
gueltion 16 A social injustice is a situation where b- equity is appli.docx
 
Grokster- along with Morpheus and Kazaa- are considered second-generat.docx
Grokster- along with Morpheus and Kazaa- are considered second-generat.docxGrokster- along with Morpheus and Kazaa- are considered second-generat.docx
Grokster- along with Morpheus and Kazaa- are considered second-generat.docx
 
Given a function declaration as below- float IncomeTax(float grossinco.docx
Given a function declaration as below- float IncomeTax(float grossinco.docxGiven a function declaration as below- float IncomeTax(float grossinco.docx
Given a function declaration as below- float IncomeTax(float grossinco.docx
 
Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docxGranite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
Granite rock- what is the texture (fine grained- phaneritic- glassy- v.docx
 
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docxGraded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
Graded Audit Task -#1 Consolidated Construction Inc-- an issuer- is a.docx
 
Governmental population policies 39- True-false- Today- almost every s.docx
Governmental population policies 39- True-false- Today- almost every s.docxGovernmental population policies 39- True-false- Today- almost every s.docx
Governmental population policies 39- True-false- Today- almost every s.docx
 
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docx
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docxGovernment Employs Backdoor Searches ACSB standards- Social and Ethica.docx
Government Employs Backdoor Searches ACSB standards- Social and Ethica.docx
 

Recently uploaded

The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 
Liberal & Redical Feminism presentation.pptx
Liberal & Redical Feminism presentation.pptxLiberal & Redical Feminism presentation.pptx
Liberal & Redical Feminism presentation.pptx
Rizwan Abbas
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
SaadHumayun7
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
中 央社
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
Keeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security ServicesKeeping Your Information Safe with Centralized Security Services
Keeping Your Information Safe with Centralized Security Services
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
Research Methods in Psychology | Cambridge AS Level | Cambridge Assessment In...
 
Liberal & Redical Feminism presentation.pptx
Liberal & Redical Feminism presentation.pptxLiberal & Redical Feminism presentation.pptx
Liberal & Redical Feminism presentation.pptx
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Neurulation and the formation of the neural tube
Neurulation and the formation of the neural tubeNeurulation and the formation of the neural tube
Neurulation and the formation of the neural tube
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdfPost Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
Post Exam Fun(da) Intra UEM General Quiz 2024 - Prelims q&a.pdf
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT VẬT LÝ 2024 - TỪ CÁC TRƯỜNG, TRƯ...
 

Getting these errors in my code I am getting error that -cannot find.docx

  • 1. Getting these errors in my code I am getting error that "cannot find symbol WarPlayer." also getting error: cannot final symbol symbol: method getCardDeck( location: variable deck of type GroupOfCards public class WarGame extends Game{ private GroupOfCards deck; final ArrayList warPool = new ArrayList<>(); private Player Player1; private Player Computer; final int cardsInDeck = 52; private Player GameWinner = null; public WarGame() { super("War"); } /** * Creates an ArrayList using the player controlled object and the computer controlled object. * This method ensures that the game is limited to 1 player and 1 computer. * * @param user */ public void createPlayerList(Player user) { Player computer = new WarPlayer("Computer"); ArrayList playerList = new ArrayList(); playerList.add(user); this.Player1 = user; playerList.add(computer); this.Computer = computer; setPlayers(playerList); } @Override public void play() { System.out.println(""); System.out.println("Starting game!"); // Instantiate GroupOfCards to create deck made up of 52 cards deck = new GroupOfCards(cardsInDeck); // Populates the deck of cards, 4 suits and 13 cards for each suit for (int r = 1; r < 14; r++) { for (int c = 0; c < 4; c++) { deck.getCardDeck().add(new Card(r, Card.suits[c])); } } // Call shuffle method from GroupOfCards and shuffle deck deck.shuffle(); System.out.println("Deck built and shuffled!"); // Create 2 ArrayList's based on the shuffled cards in the deck (one for the user, one for the computer) ArrayList userCards = new ArrayList<>(); ArrayList computerCards = new ArrayList<>(); // Even cards are added to user ArrayList, odd cards are added to computer ArrayList for (int i = 0; i < deck.getCardDeck().size(); i++) { if (i % 2 == 0) { userCards.add(deck.getCardDeck().get(i)); } else { computerCards.add(deck.getCardDeck().get(i)); } } // Create 2 GroupOfCards deck objects using the size of the 2 ArrayLists GroupOfCards playerDeck = new GroupOfCards(userCards.size()); GroupOfCards computerDeck = new GroupOfCards(computerCards.size()); // Set the cards in these GroupOfCards objects to the ones that were placed in the 2 ArrayLists earlier playerDeck.setCardDeck(userCards); computerDeck.setCardDeck(computerCards); // Give the 2 GroupsOfCards to the player objects Player1.setCards(playerDeck); Computer.setCards(computerDeck); // Clear the userCards ArrayList and the computerCards ArrayList to be used as each players discard pile userCards.clear(); computerCards.clear(); System.out.println("Deck split and distributed!"); System.out.println(""); // Draw the top card in each players deck int index = 0; boolean runGame = true; while (runGame) { // When a player runs out of cards, the game ends if (Player1.getCards().getSize() == 0 || Computer.getCards().getSize() == 0) { runGame = false; break; } System.out.println("Drawing cards!"); // Draws top card of both players decks Card playerTopCard = Player1.getCards().getTopCard(); System.out.println(Player1.getName() + " drew: " + playerTopCard.toString()); Card computerTopCard = Computer.getCards().getTopCard(); System.out.println(Computer.getName() + " drew: " + computerTopCard.toString()); System.out.println(""); //Compares the 2 cards that were drawn System.out.println("Comparing cards!"); Player roundWinner = compareCards(playerTopCard, computerTopCard); if (roundWinner == Player1) { System.out.println(Player1.getName() + " wins the hand!"); userCards.add(playerTopCard); userCards.add(computerTopCard); } else if (roundWinner == Computer) { System.out.println(Computer.getName() + " wins the hand!"); computerCards.add(playerTopCard); computerCards.add(computerTopCard); } else { System.out.println("Stalemate! Cards added to pot."); System.out.println(""); warPool.add(playerTopCard); warPool.add(computerTopCard); startWar(userCards,
  • 2. computerCards); } System.out.println(""); index++; } if (userCards.size() > computerCards.size()) { GameWinner = Player1; } else if (userCards.size() < computerCards.size()) { GameWinner = Computer; } } public Player compareCards(Card playerCard, Card computerCard) { // Holds the value of each card in a variable so that it can be referenced quickly int playerCardValue = playerCard.getCardNum(); int computerCardValue = computerCard.getCardNum(); // Checks if the value of the cards are equal if (playerCardValue != computerCardValue) { // if they are not equal, the winner will be the player with the higher value card if (playerCardValue > computerCardValue) { return Player1; } else { return Computer; } // if they are equal, the players go to war } else { return null; } } public void startWar(ArrayList userCard, ArrayList computerCard) { System.out.println("War has broken out! Each player draws 4 cards."); if (Player1.getCards().getSize() > 3 && Computer.getCards().getSize() > 3) { int war = 3; // 3 Cards into the pool for (int i = 0; i < war; i++) { warPool.add(Player1.getCards().getTopCard()); warPool.add(Computer.getCards().getTopCard()); } } Card playerFinalCard = Player1.getCards().getTopCard(); System.out.println(Player1.getName() + "'s top card is: " + playerFinalCard.toString()); Card computerFinalCard = Computer.getCards().getTopCard(); System.out.println(Computer.getName() + "'s top card is: " + computerFinalCard.toString()); warPool.add(playerFinalCard); warPool.add(computerFinalCard); System.out.println(""); Player warWinner = compareCards(playerFinalCard, computerFinalCard); if (warWinner == Player1) { System.out.println(Player1.getName() + " wins the war! Pot goes to winner!"); userCard.addAll(warPool); warPool.clear(); } else if (warWinner == Computer) { System.out.println(Computer.getName() + " wins the war! Pot goes to winner!"); computerCard.addAll(warPool); warPool.clear(); } else { System.out.println("Stalemate! A new war will soon breakout..."); startWar(userCard, computerCard); } System.out.println(""); } @Override public void declareWinner() { if (GameWinner == null) { System.out.println("No winner!"); } else if (GameWinner == Player1) { System.out.println("Winner is Player 1."); } else if (GameWinner == Computer) { System.out.println("Winner is Computer."); } } } getting error Player computer = new WarPlayer("Computer");