Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use the MyIO above to do the question. Write a complete java program to c

ID: 3857640 • Letter: P

Question

Please use the MyIO above to do the question.

Write a complete java program to create two array of Die each 100 elements call it ard1 and ard2.

Provide method named printArray that take an array of Die and print its content using toString () method of Die object. You are using MyIO class for your output to look nice.

Provide method name throwArrayOfDie that takes an array of Die and use its method rollDie () to change Its face.

Write another method that takes two array of Die and return true if ard1[i].getFace() == ard2[i].getFace()

Write another method to take one array of Die and return sum of value on each die face.

The following class MylO is a tools that I wrote to help better input/ output. If you type it and place it in same directory that your programs are or in ProjectForder In NetBeans. It will be good. Try this.. MylO.display("I am learning java", Color.YELLOW,Color.BLUE); If you like it you can add more Methods to make it better as you go. import java.awt.* import javax.swing.*; import java.awt.event.*; import javax.swing.event.; import java.util.; import java.io.* public class MylO public static int getlnt(String s)

Explanation / Answer

import java.util.*;
import java.io.*;
import java.util.Random;

public class Die// Die implementation
{
private int face;
  
// Return face of die
int getFace()
{
return face;
}
// Generate random number from 1 to 6 and update face
static void rollDie(Die d)
{
int randomInt = new Random().nextInt(6);
d.face = randomInt;
}
  
//Print array of die using myIO class
static void printArray(Die[] ard)
{
String ardString = ard.toString();
MyIO io = new MyIO();
io.display(ardString, Color.YELLOW, Color.BLUE);
}
  
//Update face of all dies in array
static void throwArrayOfDie(Die[] ard)
{
for(Die die : ard)
{
die.rollDie(die);
}
}
  
// Comapre face of dies of two arrays
boolean compare(Die[] ard1, Die[] ard2)
{
for(int i=0;i< ard1.length;i++)
{
if (ard1[i].getFace() != ard2[i].getFace())
return false;
}
return true;
}
  
//Return sum of faces of dies in array
static int getSum(Die[] ard)
{
int sum = 0;
for(Die die : ard)
{
sum += die.getFace();
}
return sum;
}
  
static void main(Sring[] args)
{
Die[] ard1 = new Die[100];
Die[] ard2 = new Die[100];
  
for(Die die : ard1)
{
die = new Die();// Instantiate array
}
  
for(Die die : ard2)
{
die = new Die();// Instantiate array
}
}
}