SlideShare uma empresa Scribd logo
1 de 6
Please help me make a UML for Java! Look at the code below and make a UML for it.
Die.Java
public class Die {
private int number_of_Sides;
private int currentSide;
public Die(int numSides) {
this.number_of_Sides = number_of_Sides;
roll();
}
public int get_Num_Sides() {
return number_of_Sides;
}
public int get_Current_Side() {
return currentSide;
}
public void roll() {
currentSide = (int) (Math.random() * number_of_Sides) + 1;
}
public String toString() {
return "Die with " + number_of_Sides + " sides showing " + currentSide;
}
}
DiceCollection.Java
public class DiceCollection {
private Die[] dice;
public DiceCollection(int[] numSidesArray) {
dice = new Die[numSidesArray.length];
for (int i = 0; i < numSidesArray.length; i++) {
dice[i] = new Die(numSidesArray[i]);
}
}
public int get_Current_Sum() {
int sum = 0;
for (Die die : dice) {
sum += die.getCurrentSide();
}
return sum;
}
public int get_Min_Possible_Sum() {
int sum = 0;
for (Die die : dice) {
sum += 1;
}
return sum;
}
public int get_Max_Possible_Sum() {
int sum = 0;
for (Die die : dice) {
sum += die.get_Num_Sides();
}
return sum;
}
public void rollAll() {
for (Die die : dice) {
die.roll();
}
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (Die die : dice) {
sb.append(die.toString() + "n");
}
sb.append("Minimum possible roll: " + getMinPossibleSum() + "n");
sb.append("Maximum possible roll: " + getMaxPossibleSum() + "n");
sb.append("Current total showing on the dice: " + getCurrentSum());
return sb.toString();
}
public int[] histogram(int numRolls) {
int[] counters = new int[getMaxPossibleSum() - getMinPossibleSum() + 1];
for (int i = 0; i < numRolls; i++) {
rollAll();
int sum = getCurrentSum();
counters[sum - getMinPossibleSum()]++;
}
return counters;
}
}
Main.java
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the no. of dice: ");
int numDice = scanner.nextInt();
int[] sides = new int[numDice];
for (int i = 0; i < numDice; i++) {
System.out.print("Enter the number of sides for die " + (i + 1) + ": ");
sides[i] = scanner.nextInt();
}
DiceCollection diceCollection = new DiceCollection(sides);
System.out.println(diceCollection);
while (true) {
System.out.println("nSelect an option:");
System.out.println("1. Roll once");
System.out.println("2. Roll 100,000 times");
System.out.println("3. Quit");
int choice = scanner.nextInt();
switch (choice) {
case 1:
diceCollection.roll();
System.out.println(diceCollection);
break;
case 2:
System.out.print("Enter the number of rolls: ");
int numRolls = scanner.nextInt();
int[] histogram = diceCollection.histogram(numRolls);
System.out.println("Histogram of " + numRolls + " rolls:");
for (int i = 0; i < histogram.length; i++) {
if (histogram[i] != 0) {
System.out.println(i + ": " + histogram[i]);
}
}
break;
case 3:
System.exit(0);
default:
System.out.println("Invalid option");
}
}
}
}
Please PUT your UML. Thank you!!

Mais conteúdo relacionado

Semelhante a UML Diagram for Die and Dice Collection Java Classes

Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Stephen Chin
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by HowardLearningTech
 
Howard type script
Howard   type scriptHoward   type script
Howard type scriptLearningTech
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.pptMahyuddin8
 
Import java
Import javaImport java
Import javaheni2121
 
Type script by Howard
Type script by HowardType script by Howard
Type script by HowardLearningTech
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...DevGAMM Conference
 
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfanandhomeneeds
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfarchanaemporium
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsSunil Yadav
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdfakkhan101
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory archana singh
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfanujsharmaanuj14
 

Semelhante a UML Diagram for Die and Dice Collection Java Classes (20)

Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)Mary Had a Little λ (QCon)
Mary Had a Little λ (QCon)
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
TypeScript by Howard
TypeScript by HowardTypeScript by Howard
TypeScript by Howard
 
Howard type script
Howard   type scriptHoward   type script
Howard type script
 
ch03-parameters-objects.ppt
ch03-parameters-objects.pptch03-parameters-objects.ppt
ch03-parameters-objects.ppt
 
Import java
Import javaImport java
Import java
 
Type script by Howard
Type script by HowardType script by Howard
Type script by Howard
 
Huraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docxHuraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docx
 
Introduzione a C#
Introduzione a C#Introduzione a C#
Introduzione a C#
 
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
Самые вкусные баги из игрового кода: как ошибаются наши коллеги-программисты ...
 
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdfDriver.java import java.util.Scanner; import java.text.Decimal.pdf
Driver.java import java.util.Scanner; import java.text.Decimal.pdf
 
I dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdfI dont know what is wrong with this roulette program I cant seem.pdf
I dont know what is wrong with this roulette program I cant seem.pdf
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
Introduction to Groovy
Introduction to GroovyIntroduction to Groovy
Introduction to Groovy
 
OrderTest.javapublic class OrderTest {       Get an arra.pdf
OrderTest.javapublic class OrderTest {         Get an arra.pdfOrderTest.javapublic class OrderTest {         Get an arra.pdf
OrderTest.javapublic class OrderTest {       Get an arra.pdf
 
Google Guava
Google GuavaGoogle Guava
Google Guava
 
QA Auotmation Java programs,theory
QA Auotmation Java programs,theory QA Auotmation Java programs,theory
QA Auotmation Java programs,theory
 
OOP v3
OOP v3OOP v3
OOP v3
 
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdfHi, Please find my codeimport java.util.Random;public class Pro.pdf
Hi, Please find my codeimport java.util.Random;public class Pro.pdf
 

Mais de JakeT2gGrayp

Please discuss the bone growth abnormality achondroplasia (achondropla.docx
Please discuss the bone growth abnormality achondroplasia (achondropla.docxPlease discuss the bone growth abnormality achondroplasia (achondropla.docx
Please discuss the bone growth abnormality achondroplasia (achondropla.docxJakeT2gGrayp
 
Please answer all questions- Will upvote! Profitability ratios help in.docx
Please answer all questions- Will upvote! Profitability ratios help in.docxPlease answer all questions- Will upvote! Profitability ratios help in.docx
Please answer all questions- Will upvote! Profitability ratios help in.docxJakeT2gGrayp
 
picture of artery and vein to label i need a plain diagram of arteries.docx
picture of artery and vein to label i need a plain diagram of arteries.docxpicture of artery and vein to label i need a plain diagram of arteries.docx
picture of artery and vein to label i need a plain diagram of arteries.docxJakeT2gGrayp
 
Please answer all questions- 1) Adaptive immunity has five distinct a.docx
Please answer all questions-  1) Adaptive immunity has five distinct a.docxPlease answer all questions-  1) Adaptive immunity has five distinct a.docx
Please answer all questions- 1) Adaptive immunity has five distinct a.docxJakeT2gGrayp
 
Photoreceptors respond to the removal of light by Group of answer choi.docx
Photoreceptors respond to the removal of light by Group of answer choi.docxPhotoreceptors respond to the removal of light by Group of answer choi.docx
Photoreceptors respond to the removal of light by Group of answer choi.docxJakeT2gGrayp
 
Please answer all questions- IMMUNIZATION Immunization or vaccination.docx
Please answer all questions-  IMMUNIZATION Immunization or vaccination.docxPlease answer all questions-  IMMUNIZATION Immunization or vaccination.docx
Please answer all questions- IMMUNIZATION Immunization or vaccination.docxJakeT2gGrayp
 
Place these phases of an audit in chronological order- A- Assess the r.docx
Place these phases of an audit in chronological order- A- Assess the r.docxPlace these phases of an audit in chronological order- A- Assess the r.docx
Place these phases of an audit in chronological order- A- Assess the r.docxJakeT2gGrayp
 
Petty Cash Fund Petty Cash Fund Libby Company established a petty cas.docx
Petty Cash Fund  Petty Cash Fund Libby Company established a petty cas.docxPetty Cash Fund  Petty Cash Fund Libby Company established a petty cas.docx
Petty Cash Fund Petty Cash Fund Libby Company established a petty cas.docxJakeT2gGrayp
 
Please answer question 4b only 4- The image below (on Endomembrane Sys.docx
Please answer question 4b only 4- The image below (on Endomembrane Sys.docxPlease answer question 4b only 4- The image below (on Endomembrane Sys.docx
Please answer question 4b only 4- The image below (on Endomembrane Sys.docxJakeT2gGrayp
 
Please answer all questions- b- The in which CD95L binds to CD95 on t.docx
Please answer all questions-  b- The in which CD95L binds to CD95 on t.docxPlease answer all questions-  b- The in which CD95L binds to CD95 on t.docx
Please answer all questions- b- The in which CD95L binds to CD95 on t.docxJakeT2gGrayp
 
Please answer all questions- T Lymphocytes (T Cells) 1) T lymphocytes.docx
Please answer all questions-  T Lymphocytes (T Cells) 1) T lymphocytes.docxPlease answer all questions-  T Lymphocytes (T Cells) 1) T lymphocytes.docx
Please answer all questions- T Lymphocytes (T Cells) 1) T lymphocytes.docxJakeT2gGrayp
 
Please answer all questions- 5- When the inflammatory mediators excee (1).docx
Please answer all questions-  5- When the inflammatory mediators excee (1).docxPlease answer all questions-  5- When the inflammatory mediators excee (1).docx
Please answer all questions- 5- When the inflammatory mediators excee (1).docxJakeT2gGrayp
 
Please answer all questions- 10- Antibody Function- The binding of an.docx
Please answer all questions-  10- Antibody Function- The binding of an.docxPlease answer all questions-  10- Antibody Function- The binding of an.docx
Please answer all questions- 10- Antibody Function- The binding of an.docxJakeT2gGrayp
 
Phosphatidate is an intermediate in the formation of- a) phospholipids.docx
Phosphatidate is an intermediate in the formation of- a) phospholipids.docxPhosphatidate is an intermediate in the formation of- a) phospholipids.docx
Phosphatidate is an intermediate in the formation of- a) phospholipids.docxJakeT2gGrayp
 
phage type of 42D- Which statement(s) are true- Check All That Apply T.docx
phage type of 42D- Which statement(s) are true- Check All That Apply T.docxphage type of 42D- Which statement(s) are true- Check All That Apply T.docx
phage type of 42D- Which statement(s) are true- Check All That Apply T.docxJakeT2gGrayp
 
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docx
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docxPequired informetion Learning Objective 03-P6- Prepare closing entries.docx
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docxJakeT2gGrayp
 
Please update the registers at the end of the program execution- Also.docx
Please update the registers at the end of the program execution- Also.docxPlease update the registers at the end of the program execution- Also.docx
Please update the registers at the end of the program execution- Also.docxJakeT2gGrayp
 
Please see below H10 table released by the Fed- Rates in currency unit.docx
Please see below H10 table released by the Fed- Rates in currency unit.docxPlease see below H10 table released by the Fed- Rates in currency unit.docx
Please see below H10 table released by the Fed- Rates in currency unit.docxJakeT2gGrayp
 
People are perceived as being more trustworthy when they- Select one-.docx
People are perceived as being more trustworthy when they- Select one-.docxPeople are perceived as being more trustworthy when they- Select one-.docx
People are perceived as being more trustworthy when they- Select one-.docxJakeT2gGrayp
 
Please make revision to the following program so it incorporates three.docx
Please make revision to the following program so it incorporates three.docxPlease make revision to the following program so it incorporates three.docx
Please make revision to the following program so it incorporates three.docxJakeT2gGrayp
 

Mais de JakeT2gGrayp (20)

Please discuss the bone growth abnormality achondroplasia (achondropla.docx
Please discuss the bone growth abnormality achondroplasia (achondropla.docxPlease discuss the bone growth abnormality achondroplasia (achondropla.docx
Please discuss the bone growth abnormality achondroplasia (achondropla.docx
 
Please answer all questions- Will upvote! Profitability ratios help in.docx
Please answer all questions- Will upvote! Profitability ratios help in.docxPlease answer all questions- Will upvote! Profitability ratios help in.docx
Please answer all questions- Will upvote! Profitability ratios help in.docx
 
picture of artery and vein to label i need a plain diagram of arteries.docx
picture of artery and vein to label i need a plain diagram of arteries.docxpicture of artery and vein to label i need a plain diagram of arteries.docx
picture of artery and vein to label i need a plain diagram of arteries.docx
 
Please answer all questions- 1) Adaptive immunity has five distinct a.docx
Please answer all questions-  1) Adaptive immunity has five distinct a.docxPlease answer all questions-  1) Adaptive immunity has five distinct a.docx
Please answer all questions- 1) Adaptive immunity has five distinct a.docx
 
Photoreceptors respond to the removal of light by Group of answer choi.docx
Photoreceptors respond to the removal of light by Group of answer choi.docxPhotoreceptors respond to the removal of light by Group of answer choi.docx
Photoreceptors respond to the removal of light by Group of answer choi.docx
 
Please answer all questions- IMMUNIZATION Immunization or vaccination.docx
Please answer all questions-  IMMUNIZATION Immunization or vaccination.docxPlease answer all questions-  IMMUNIZATION Immunization or vaccination.docx
Please answer all questions- IMMUNIZATION Immunization or vaccination.docx
 
Place these phases of an audit in chronological order- A- Assess the r.docx
Place these phases of an audit in chronological order- A- Assess the r.docxPlace these phases of an audit in chronological order- A- Assess the r.docx
Place these phases of an audit in chronological order- A- Assess the r.docx
 
Petty Cash Fund Petty Cash Fund Libby Company established a petty cas.docx
Petty Cash Fund  Petty Cash Fund Libby Company established a petty cas.docxPetty Cash Fund  Petty Cash Fund Libby Company established a petty cas.docx
Petty Cash Fund Petty Cash Fund Libby Company established a petty cas.docx
 
Please answer question 4b only 4- The image below (on Endomembrane Sys.docx
Please answer question 4b only 4- The image below (on Endomembrane Sys.docxPlease answer question 4b only 4- The image below (on Endomembrane Sys.docx
Please answer question 4b only 4- The image below (on Endomembrane Sys.docx
 
Please answer all questions- b- The in which CD95L binds to CD95 on t.docx
Please answer all questions-  b- The in which CD95L binds to CD95 on t.docxPlease answer all questions-  b- The in which CD95L binds to CD95 on t.docx
Please answer all questions- b- The in which CD95L binds to CD95 on t.docx
 
Please answer all questions- T Lymphocytes (T Cells) 1) T lymphocytes.docx
Please answer all questions-  T Lymphocytes (T Cells) 1) T lymphocytes.docxPlease answer all questions-  T Lymphocytes (T Cells) 1) T lymphocytes.docx
Please answer all questions- T Lymphocytes (T Cells) 1) T lymphocytes.docx
 
Please answer all questions- 5- When the inflammatory mediators excee (1).docx
Please answer all questions-  5- When the inflammatory mediators excee (1).docxPlease answer all questions-  5- When the inflammatory mediators excee (1).docx
Please answer all questions- 5- When the inflammatory mediators excee (1).docx
 
Please answer all questions- 10- Antibody Function- The binding of an.docx
Please answer all questions-  10- Antibody Function- The binding of an.docxPlease answer all questions-  10- Antibody Function- The binding of an.docx
Please answer all questions- 10- Antibody Function- The binding of an.docx
 
Phosphatidate is an intermediate in the formation of- a) phospholipids.docx
Phosphatidate is an intermediate in the formation of- a) phospholipids.docxPhosphatidate is an intermediate in the formation of- a) phospholipids.docx
Phosphatidate is an intermediate in the formation of- a) phospholipids.docx
 
phage type of 42D- Which statement(s) are true- Check All That Apply T.docx
phage type of 42D- Which statement(s) are true- Check All That Apply T.docxphage type of 42D- Which statement(s) are true- Check All That Apply T.docx
phage type of 42D- Which statement(s) are true- Check All That Apply T.docx
 
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docx
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docxPequired informetion Learning Objective 03-P6- Prepare closing entries.docx
Pequired informetion Learning Objective 03-P6- Prepare closing entries.docx
 
Please update the registers at the end of the program execution- Also.docx
Please update the registers at the end of the program execution- Also.docxPlease update the registers at the end of the program execution- Also.docx
Please update the registers at the end of the program execution- Also.docx
 
Please see below H10 table released by the Fed- Rates in currency unit.docx
Please see below H10 table released by the Fed- Rates in currency unit.docxPlease see below H10 table released by the Fed- Rates in currency unit.docx
Please see below H10 table released by the Fed- Rates in currency unit.docx
 
People are perceived as being more trustworthy when they- Select one-.docx
People are perceived as being more trustworthy when they- Select one-.docxPeople are perceived as being more trustworthy when they- Select one-.docx
People are perceived as being more trustworthy when they- Select one-.docx
 
Please make revision to the following program so it incorporates three.docx
Please make revision to the following program so it incorporates three.docxPlease make revision to the following program so it incorporates three.docx
Please make revision to the following program so it incorporates three.docx
 

Último

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 

Último (20)

Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
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🔝
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 

UML Diagram for Die and Dice Collection Java Classes

  • 1. Please help me make a UML for Java! Look at the code below and make a UML for it. Die.Java public class Die { private int number_of_Sides; private int currentSide; public Die(int numSides) { this.number_of_Sides = number_of_Sides; roll(); } public int get_Num_Sides() { return number_of_Sides; } public int get_Current_Side() { return currentSide; } public void roll() { currentSide = (int) (Math.random() * number_of_Sides) + 1; } public String toString() { return "Die with " + number_of_Sides + " sides showing " + currentSide; } } DiceCollection.Java
  • 2. public class DiceCollection { private Die[] dice; public DiceCollection(int[] numSidesArray) { dice = new Die[numSidesArray.length]; for (int i = 0; i < numSidesArray.length; i++) { dice[i] = new Die(numSidesArray[i]); } } public int get_Current_Sum() { int sum = 0; for (Die die : dice) { sum += die.getCurrentSide(); } return sum; } public int get_Min_Possible_Sum() { int sum = 0; for (Die die : dice) { sum += 1; } return sum; } public int get_Max_Possible_Sum() {
  • 3. int sum = 0; for (Die die : dice) { sum += die.get_Num_Sides(); } return sum; } public void rollAll() { for (Die die : dice) { die.roll(); } } public String toString() { StringBuilder sb = new StringBuilder(); for (Die die : dice) { sb.append(die.toString() + "n"); } sb.append("Minimum possible roll: " + getMinPossibleSum() + "n"); sb.append("Maximum possible roll: " + getMaxPossibleSum() + "n"); sb.append("Current total showing on the dice: " + getCurrentSum()); return sb.toString(); } public int[] histogram(int numRolls) { int[] counters = new int[getMaxPossibleSum() - getMinPossibleSum() + 1];
  • 4. for (int i = 0; i < numRolls; i++) { rollAll(); int sum = getCurrentSum(); counters[sum - getMinPossibleSum()]++; } return counters; } } Main.java public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the no. of dice: "); int numDice = scanner.nextInt(); int[] sides = new int[numDice]; for (int i = 0; i < numDice; i++) { System.out.print("Enter the number of sides for die " + (i + 1) + ": "); sides[i] = scanner.nextInt(); } DiceCollection diceCollection = new DiceCollection(sides); System.out.println(diceCollection); while (true) { System.out.println("nSelect an option:");
  • 5. System.out.println("1. Roll once"); System.out.println("2. Roll 100,000 times"); System.out.println("3. Quit"); int choice = scanner.nextInt(); switch (choice) { case 1: diceCollection.roll(); System.out.println(diceCollection); break; case 2: System.out.print("Enter the number of rolls: "); int numRolls = scanner.nextInt(); int[] histogram = diceCollection.histogram(numRolls); System.out.println("Histogram of " + numRolls + " rolls:"); for (int i = 0; i < histogram.length; i++) { if (histogram[i] != 0) { System.out.println(i + ": " + histogram[i]); } } break; case 3: System.exit(0); default: