SlideShare a Scribd company logo
1 of 12
Download to read offline
This is the final code which meets your requirement.Than you
Card.java
import java.util.Random;
public class Card {
//declaring instance variables
private String suit;
private int face_value;
public static int count=52;
//Creating an instance of Random class reference
Random rand;
//Default Constructor
public Card() {
super();
//Passing random class object to the Random class reference
rand = new Random();
}
//Getters and setters
public String getSuit() {
return suit;
}
public void setSuit(String suit) {
this.suit = suit;
}
public int getFace_value() {
return face_value;
}
public void setFace_value(int face_value) {
this.face_value = face_value;
}
public int getCount() {
return count;
}
//This shuffle() method will shuffle the deck
public void shuffle()
{
//Picking a card from the deck randomly and find its face value and suit
this.face_value = 1 + rand.nextInt((9) + 1);
int suit_random_value = 1 + rand.nextInt((3) + 1);
if(suit_random_value==1)
{
this.suit="Clubs";
}
else if(suit_random_value==2)
{
this.suit="hearts";
}
else if(suit_random_value==3)
{
this.suit="Spades";
}
else if(suit_random_value==4)
{
this.suit="diamonds";
}
this.count=count-1;
}
}
________________________________________________________________________
DriverClass.java
public class DriverClass {
public static void main(String[] args) {
//creating an array which can hold 52 Card class Objects
Card c[]=new Card[52];
//Creating 52 card class objects and storing them into an array
for(int i=0;i<52;i++)
{
//Creating Card class Object
c[i]=new Card();
}
//Displaying each card face value and its suit.
for(int i=0;i<52;i++)
{
//Shuffling the deck before every card picking from the deck
c[i].shuffle();
//Displaying randomly picked card face value and its suit
System.out.println(c[i].getFace_value()+" of "+c[i].getSuit()+" Cards remaining
"+c[i].getCount());
}
}
}
_________________________________________________________________________
Output:
8 of diamonds
Cards remaining 51
4 of Clubs
Cards remaining 50
9 of Clubs
Cards remaining 49
7 of Spades
Cards remaining 48
9 of diamonds
Cards remaining 47
7 of diamonds
Cards remaining 46
4 of diamonds
Cards remaining 45
9 of Clubs
Cards remaining 44
5 of hearts
Cards remaining 43
7 of Spades
Cards remaining 42
10 of Clubs
Cards remaining 41
7 of diamonds
Cards remaining 40
8 of diamonds
Cards remaining 39
6 of hearts
Cards remaining 38
4 of hearts
Cards remaining 37
6 of Spades
Cards remaining 36
4 of Clubs
Cards remaining 35
3 of diamonds
Cards remaining 34
9 of diamonds
Cards remaining 33
3 of diamonds
Cards remaining 32
5 of Spades
Cards remaining 31
4 of Clubs
Cards remaining 30
3 of Spades
Cards remaining 29
6 of diamonds
Cards remaining 28
3 of hearts
Cards remaining 27
9 of hearts
Cards remaining 26
7 of hearts
Cards remaining 25
3 of hearts
Cards remaining 24
10 of Clubs
Cards remaining 23
2 of hearts
Cards remaining 22
9 of Clubs
Cards remaining 21
8 of diamonds
Cards remaining 20
8 of Clubs
Cards remaining 19
2 of hearts
Cards remaining 18
9 of Clubs
Cards remaining 17
8 of diamonds
Cards remaining 16
5 of Spades
Cards remaining 15
4 of Spades
Cards remaining 14
5 of Clubs
Cards remaining 13
3 of Clubs
Cards remaining 12
8 of diamonds
Cards remaining 11
9 of Clubs
Cards remaining 10
4 of Clubs
Cards remaining 9
10 of Clubs
Cards remaining 8
1 of hearts
Cards remaining 7
5 of Spades
Cards remaining 6
1 of hearts
Cards remaining 5
4 of Clubs
Cards remaining 4
10 of Clubs
Cards remaining 3
3 of diamonds
Cards remaining 2
3 of hearts
Cards remaining 1
8 of Clubs
Cards remaining 0
_________________________________________________________________________
Solution
This is the final code which meets your requirement.Than you
Card.java
import java.util.Random;
public class Card {
//declaring instance variables
private String suit;
private int face_value;
public static int count=52;
//Creating an instance of Random class reference
Random rand;
//Default Constructor
public Card() {
super();
//Passing random class object to the Random class reference
rand = new Random();
}
//Getters and setters
public String getSuit() {
return suit;
}
public void setSuit(String suit) {
this.suit = suit;
}
public int getFace_value() {
return face_value;
}
public void setFace_value(int face_value) {
this.face_value = face_value;
}
public int getCount() {
return count;
}
//This shuffle() method will shuffle the deck
public void shuffle()
{
//Picking a card from the deck randomly and find its face value and suit
this.face_value = 1 + rand.nextInt((9) + 1);
int suit_random_value = 1 + rand.nextInt((3) + 1);
if(suit_random_value==1)
{
this.suit="Clubs";
}
else if(suit_random_value==2)
{
this.suit="hearts";
}
else if(suit_random_value==3)
{
this.suit="Spades";
}
else if(suit_random_value==4)
{
this.suit="diamonds";
}
this.count=count-1;
}
}
________________________________________________________________________
DriverClass.java
public class DriverClass {
public static void main(String[] args) {
//creating an array which can hold 52 Card class Objects
Card c[]=new Card[52];
//Creating 52 card class objects and storing them into an array
for(int i=0;i<52;i++)
{
//Creating Card class Object
c[i]=new Card();
}
//Displaying each card face value and its suit.
for(int i=0;i<52;i++)
{
//Shuffling the deck before every card picking from the deck
c[i].shuffle();
//Displaying randomly picked card face value and its suit
System.out.println(c[i].getFace_value()+" of "+c[i].getSuit()+" Cards remaining
"+c[i].getCount());
}
}
}
_________________________________________________________________________
Output:
8 of diamonds
Cards remaining 51
4 of Clubs
Cards remaining 50
9 of Clubs
Cards remaining 49
7 of Spades
Cards remaining 48
9 of diamonds
Cards remaining 47
7 of diamonds
Cards remaining 46
4 of diamonds
Cards remaining 45
9 of Clubs
Cards remaining 44
5 of hearts
Cards remaining 43
7 of Spades
Cards remaining 42
10 of Clubs
Cards remaining 41
7 of diamonds
Cards remaining 40
8 of diamonds
Cards remaining 39
6 of hearts
Cards remaining 38
4 of hearts
Cards remaining 37
6 of Spades
Cards remaining 36
4 of Clubs
Cards remaining 35
3 of diamonds
Cards remaining 34
9 of diamonds
Cards remaining 33
3 of diamonds
Cards remaining 32
5 of Spades
Cards remaining 31
4 of Clubs
Cards remaining 30
3 of Spades
Cards remaining 29
6 of diamonds
Cards remaining 28
3 of hearts
Cards remaining 27
9 of hearts
Cards remaining 26
7 of hearts
Cards remaining 25
3 of hearts
Cards remaining 24
10 of Clubs
Cards remaining 23
2 of hearts
Cards remaining 22
9 of Clubs
Cards remaining 21
8 of diamonds
Cards remaining 20
8 of Clubs
Cards remaining 19
2 of hearts
Cards remaining 18
9 of Clubs
Cards remaining 17
8 of diamonds
Cards remaining 16
5 of Spades
Cards remaining 15
4 of Spades
Cards remaining 14
5 of Clubs
Cards remaining 13
3 of Clubs
Cards remaining 12
8 of diamonds
Cards remaining 11
9 of Clubs
Cards remaining 10
4 of Clubs
Cards remaining 9
10 of Clubs
Cards remaining 8
1 of hearts
Cards remaining 7
5 of Spades
Cards remaining 6
1 of hearts
Cards remaining 5
4 of Clubs
Cards remaining 4
10 of Clubs
Cards remaining 3
3 of diamonds
Cards remaining 2
3 of hearts
Cards remaining 1
8 of Clubs
Cards remaining 0
_________________________________________________________________________

More Related Content

Similar to This is the final code which meets your requirement.Than youCard.j.pdf

Domain Modeling Made Functional (DevTernity 2022)
Domain Modeling Made Functional (DevTernity 2022)Domain Modeling Made Functional (DevTernity 2022)
Domain Modeling Made Functional (DevTernity 2022)Scott Wlaschin
 
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.pdfcharanjit1717
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Scott Wlaschin
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxAustinIKkNorthy
 
Introduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdfIntroduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdffeelinggifts
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Scott Wlaschin
 
Comp 220 i lab 1 two dimensional arrays lab report and source code
Comp 220 i lab 1 two dimensional arrays lab report and source codeComp 220 i lab 1 two dimensional arrays lab report and source code
Comp 220 i lab 1 two dimensional arrays lab report and source codepradesigali1
 

Similar to This is the final code which meets your requirement.Than youCard.j.pdf (8)

Domain Modeling Made Functional (DevTernity 2022)
Domain Modeling Made Functional (DevTernity 2022)Domain Modeling Made Functional (DevTernity 2022)
Domain Modeling Made Functional (DevTernity 2022)
 
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
 
Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)Domain Modeling Made Functional (KanDDDinsky 2019)
Domain Modeling Made Functional (KanDDDinsky 2019)
 
Puzzle with sql set
Puzzle with sql   setPuzzle with sql   set
Puzzle with sql set
 
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docxThere are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
There are 5 C++ files below- Card-h- Card-cpp- Deck-h- Deck-cpp- Main-.docx
 
Introduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdfIntroduction You implemented a Deck class in Activity 2. This cla.pdf
Introduction You implemented a Deck class in Activity 2. This cla.pdf
 
Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)Domain Modeling with FP (DDD Europe 2020)
Domain Modeling with FP (DDD Europe 2020)
 
Comp 220 i lab 1 two dimensional arrays lab report and source code
Comp 220 i lab 1 two dimensional arrays lab report and source codeComp 220 i lab 1 two dimensional arrays lab report and source code
Comp 220 i lab 1 two dimensional arrays lab report and source code
 

More from aplolomedicalstoremr

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfaplolomedicalstoremr
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfaplolomedicalstoremr
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfaplolomedicalstoremr
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfaplolomedicalstoremr
 
Polygon .java package chegg2;public class Polygon { Var.pdf
Polygon .java package chegg2;public class Polygon {  Var.pdfPolygon .java package chegg2;public class Polygon {  Var.pdf
Polygon .java package chegg2;public class Polygon { Var.pdfaplolomedicalstoremr
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfaplolomedicalstoremr
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfaplolomedicalstoremr
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfaplolomedicalstoremr
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfaplolomedicalstoremr
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfaplolomedicalstoremr
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfaplolomedicalstoremr
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfaplolomedicalstoremr
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfaplolomedicalstoremr
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfaplolomedicalstoremr
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdfaplolomedicalstoremr
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfaplolomedicalstoremr
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfaplolomedicalstoremr
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfaplolomedicalstoremr
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdfaplolomedicalstoremr
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfaplolomedicalstoremr
 

More from aplolomedicalstoremr (20)

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdf
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdf
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
 
Polygon .java package chegg2;public class Polygon { Var.pdf
Polygon .java package chegg2;public class Polygon {  Var.pdfPolygon .java package chegg2;public class Polygon {  Var.pdf
Polygon .java package chegg2;public class Polygon { Var.pdf
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdf
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 

Recently uploaded (20)

9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 

This is the final code which meets your requirement.Than youCard.j.pdf

  • 1. This is the final code which meets your requirement.Than you Card.java import java.util.Random; public class Card { //declaring instance variables private String suit; private int face_value; public static int count=52; //Creating an instance of Random class reference Random rand; //Default Constructor public Card() { super(); //Passing random class object to the Random class reference rand = new Random(); } //Getters and setters public String getSuit() { return suit; } public void setSuit(String suit) { this.suit = suit; } public int getFace_value() { return face_value; } public void setFace_value(int face_value) { this.face_value = face_value; } public int getCount() {
  • 2. return count; } //This shuffle() method will shuffle the deck public void shuffle() { //Picking a card from the deck randomly and find its face value and suit this.face_value = 1 + rand.nextInt((9) + 1); int suit_random_value = 1 + rand.nextInt((3) + 1); if(suit_random_value==1) { this.suit="Clubs"; } else if(suit_random_value==2) { this.suit="hearts"; } else if(suit_random_value==3) { this.suit="Spades"; } else if(suit_random_value==4) { this.suit="diamonds"; } this.count=count-1; } } ________________________________________________________________________ DriverClass.java public class DriverClass { public static void main(String[] args) {
  • 3. //creating an array which can hold 52 Card class Objects Card c[]=new Card[52]; //Creating 52 card class objects and storing them into an array for(int i=0;i<52;i++) { //Creating Card class Object c[i]=new Card(); } //Displaying each card face value and its suit. for(int i=0;i<52;i++) { //Shuffling the deck before every card picking from the deck c[i].shuffle(); //Displaying randomly picked card face value and its suit System.out.println(c[i].getFace_value()+" of "+c[i].getSuit()+" Cards remaining "+c[i].getCount()); } } } _________________________________________________________________________ Output: 8 of diamonds Cards remaining 51 4 of Clubs Cards remaining 50 9 of Clubs Cards remaining 49 7 of Spades Cards remaining 48 9 of diamonds Cards remaining 47 7 of diamonds Cards remaining 46
  • 4. 4 of diamonds Cards remaining 45 9 of Clubs Cards remaining 44 5 of hearts Cards remaining 43 7 of Spades Cards remaining 42 10 of Clubs Cards remaining 41 7 of diamonds Cards remaining 40 8 of diamonds Cards remaining 39 6 of hearts Cards remaining 38 4 of hearts Cards remaining 37 6 of Spades Cards remaining 36 4 of Clubs Cards remaining 35 3 of diamonds Cards remaining 34 9 of diamonds Cards remaining 33 3 of diamonds Cards remaining 32 5 of Spades Cards remaining 31 4 of Clubs Cards remaining 30 3 of Spades Cards remaining 29 6 of diamonds Cards remaining 28
  • 5. 3 of hearts Cards remaining 27 9 of hearts Cards remaining 26 7 of hearts Cards remaining 25 3 of hearts Cards remaining 24 10 of Clubs Cards remaining 23 2 of hearts Cards remaining 22 9 of Clubs Cards remaining 21 8 of diamonds Cards remaining 20 8 of Clubs Cards remaining 19 2 of hearts Cards remaining 18 9 of Clubs Cards remaining 17 8 of diamonds Cards remaining 16 5 of Spades Cards remaining 15 4 of Spades Cards remaining 14 5 of Clubs Cards remaining 13 3 of Clubs Cards remaining 12 8 of diamonds Cards remaining 11 9 of Clubs Cards remaining 10
  • 6. 4 of Clubs Cards remaining 9 10 of Clubs Cards remaining 8 1 of hearts Cards remaining 7 5 of Spades Cards remaining 6 1 of hearts Cards remaining 5 4 of Clubs Cards remaining 4 10 of Clubs Cards remaining 3 3 of diamonds Cards remaining 2 3 of hearts Cards remaining 1 8 of Clubs Cards remaining 0 _________________________________________________________________________ Solution This is the final code which meets your requirement.Than you Card.java import java.util.Random; public class Card { //declaring instance variables private String suit; private int face_value; public static int count=52; //Creating an instance of Random class reference Random rand;
  • 7. //Default Constructor public Card() { super(); //Passing random class object to the Random class reference rand = new Random(); } //Getters and setters public String getSuit() { return suit; } public void setSuit(String suit) { this.suit = suit; } public int getFace_value() { return face_value; } public void setFace_value(int face_value) { this.face_value = face_value; } public int getCount() { return count; } //This shuffle() method will shuffle the deck public void shuffle() { //Picking a card from the deck randomly and find its face value and suit this.face_value = 1 + rand.nextInt((9) + 1); int suit_random_value = 1 + rand.nextInt((3) + 1); if(suit_random_value==1) { this.suit="Clubs"; }
  • 8. else if(suit_random_value==2) { this.suit="hearts"; } else if(suit_random_value==3) { this.suit="Spades"; } else if(suit_random_value==4) { this.suit="diamonds"; } this.count=count-1; } } ________________________________________________________________________ DriverClass.java public class DriverClass { public static void main(String[] args) { //creating an array which can hold 52 Card class Objects Card c[]=new Card[52]; //Creating 52 card class objects and storing them into an array for(int i=0;i<52;i++) { //Creating Card class Object c[i]=new Card(); } //Displaying each card face value and its suit. for(int i=0;i<52;i++) {
  • 9. //Shuffling the deck before every card picking from the deck c[i].shuffle(); //Displaying randomly picked card face value and its suit System.out.println(c[i].getFace_value()+" of "+c[i].getSuit()+" Cards remaining "+c[i].getCount()); } } } _________________________________________________________________________ Output: 8 of diamonds Cards remaining 51 4 of Clubs Cards remaining 50 9 of Clubs Cards remaining 49 7 of Spades Cards remaining 48 9 of diamonds Cards remaining 47 7 of diamonds Cards remaining 46 4 of diamonds Cards remaining 45 9 of Clubs Cards remaining 44 5 of hearts Cards remaining 43 7 of Spades Cards remaining 42 10 of Clubs Cards remaining 41 7 of diamonds Cards remaining 40 8 of diamonds
  • 10. Cards remaining 39 6 of hearts Cards remaining 38 4 of hearts Cards remaining 37 6 of Spades Cards remaining 36 4 of Clubs Cards remaining 35 3 of diamonds Cards remaining 34 9 of diamonds Cards remaining 33 3 of diamonds Cards remaining 32 5 of Spades Cards remaining 31 4 of Clubs Cards remaining 30 3 of Spades Cards remaining 29 6 of diamonds Cards remaining 28 3 of hearts Cards remaining 27 9 of hearts Cards remaining 26 7 of hearts Cards remaining 25 3 of hearts Cards remaining 24 10 of Clubs Cards remaining 23 2 of hearts Cards remaining 22 9 of Clubs
  • 11. Cards remaining 21 8 of diamonds Cards remaining 20 8 of Clubs Cards remaining 19 2 of hearts Cards remaining 18 9 of Clubs Cards remaining 17 8 of diamonds Cards remaining 16 5 of Spades Cards remaining 15 4 of Spades Cards remaining 14 5 of Clubs Cards remaining 13 3 of Clubs Cards remaining 12 8 of diamonds Cards remaining 11 9 of Clubs Cards remaining 10 4 of Clubs Cards remaining 9 10 of Clubs Cards remaining 8 1 of hearts Cards remaining 7 5 of Spades Cards remaining 6 1 of hearts Cards remaining 5 4 of Clubs Cards remaining 4 10 of Clubs
  • 12. Cards remaining 3 3 of diamonds Cards remaining 2 3 of hearts Cards remaining 1 8 of Clubs Cards remaining 0 _________________________________________________________________________