Question: An instance of the DiskModel class represents the ArrayList of Disk objects that have been placed on the board. You should add a field to

 An instance of the DiskModel class represents the ArrayList of Disk

An instance of the DiskModel class represents the ArrayList of Disk objects that have been placed on the board. You should add a field to the class for this list.

You must implement 4 methods:

  • A constructor that takes no parameters which initializes the empty ArrayList field
  • A getDisks method which returns the ArrayList object
  • A getNumDisks method which returns the number of Disks currently stored in the ArrayList
  • An addDisk method which adds the disk parameter to the models ArrayList

My question is did I do it right...if not. How do I properly add an arraylist. And how to you use or put into the publlic void addDisk(Disk disk)

Disk.java DiskColor.java DiskModel.java X DisksApp.java Disks Panel.java 2 3e /** 4 * The model for the disk game 5 * which stores and ArrayList of Disks 6 */ 7 public class DiskModel { 28 // TODO: add fields. 9 100 /** 11 * Constructor. 12 * Creates empty ArrayList 13 */ 140 public DiskModel() { 0.15 ArrayList arrList = new ArrayList(); 16 17 } 18 19 /** 20 * @return the ArrayList of Disks 21 22 public ArrayList getDisks() { 23 return getDisks(); 24 } 25 26 /** 27 @return the number of placed disks 28 */ 290 public int getNumDisks() { 30 return getNumDisks(); 31 } 32 330 /** 34 * Add a new disk to the ArrayList 35 36 @param disk Disk to add 37 38 public void addDisk (Disk disk) { 39 ; 40 } 41 42 } 20 2 Disk.java DiskColor.java DiskModel.java X DisksApp.java Disks Panel.java 2 3e /** 4 * The model for the disk game 5 * which stores and ArrayList of Disks 6 */ 7 public class DiskModel { 28 // TODO: add fields. 9 100 /** 11 * Constructor. 12 * Creates empty ArrayList 13 */ 140 public DiskModel() { 0.15 ArrayList arrList = new ArrayList(); 16 17 } 18 19 /** 20 * @return the ArrayList of Disks 21 22 public ArrayList getDisks() { 23 return getDisks(); 24 } 25 26 /** 27 @return the number of placed disks 28 */ 290 public int getNumDisks() { 30 return getNumDisks(); 31 } 32 330 /** 34 * Add a new disk to the ArrayList 35 36 @param disk Disk to add 37 38 public void addDisk (Disk disk) { 39 ; 40 } 41 42 } 20 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!