SlideShare una empresa de Scribd logo
1 de 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");

Más contenido relacionado

Similar a 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 a 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
 

Más de 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
 

Más de 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
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 

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");