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

The data for all the paintings is stored in a class called ArtMuseum. This class

ID: 3633216 • Letter: T

Question

The data for all the paintings is stored in a class called ArtMuseum. This class uses an array to hold Painting objects. The problem is to complete the definition of the methods in the class ArtMuseum. (

public class ArtMuseum {

private Painting paintings = new Painting[200];
private int paintingCount;

public void addPainting(Painting painting) {

// add new painting to the end of the
// paintings array







}

public void addPainting(String description, String artist, double value) {

// add new painting with (description, artist and
// value) to the end of the paintings array







}


public boolean findPainting(String artist) {

// Find a painting with artist
// "artist" in the array.
// If the painting is found in the array,
// return true otherwise false should be
// returned.















}


}

Explanation / Answer

public class ArtMuseum {

private Painting paintings = new Painting[200];
private int paintingCount;

public void addPainting(Painting painting) {

// add new painting to the end of the
// paintings array
paintings[paintingCount++] = painting;






}

public void addPainting(String description, String artist, double value) {

// add new painting with (description, artist and
// value) to the end of the paintings array

paintings[paintingCount].description = description;


paintings[paintingCount].artist= artist;

paintings[paintingCount].value= value;

}


public boolean findPainting(String artist) {

for(int i=0; i<paintingCount; i++)

{

if(paintings[i].artist.equals(artist))

System.out.println( artist + " found ");

}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote