Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Join our platform to connect with experts ready to provide detailed answers to your questions in various areas. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.

For this exercise, you are given the Picture class and the PictureTester class. The Picture class has two instance variables. You will need to finish the class by writing getter and setter methods for these two instance variables.
Then in the PictureTester class a Picture object has been created for you. You will need to update this object and then print using the getter methods you created.
public class Picture
{
private String name;
private String date;
public Picture(String theName, String theDate){
name = theName;
date = theDate;
}
// Add getter and setter methods here.
// method names should be:
// getName, setName, getDate, setDate
}


Sagot :

Answer:

hope this helps, do consider giving brainliest

Explanation:

public class Picture {

  

   // two instance variables

   private String name;

   private String date;

  

   // Parameterized constructor

   public Picture(String name, String date) {

       super();

       this.name = name;

       this.date = date;

   }

  

   /**

   * return the name

   */

   public String getName() {

       return name;

   }

   /**

   * param name the name to set

   */

   public void setName(String name) {

       this.name = name;

   }

   /**

   * return the date

   */

   public String getDate() {

       return date;

   }

   /**

   * param date the date to set

   */

   public void setDate(String date) {

       this.date = date;

   }  

}

----------------------------------------------------TESTER CLASS---------------------------------------------------------------------

package test;

public class PictureTester {

   public static void main(String[] args) {

       // TODO Auto-generated method stub

       // creating Picture object (pic is the reference variable) and we are invoking the constructor by passing // values of name and date

      

       Picture pic = new Picture("flower_pic", "28-04-2020");

      

       // now we will first use get method

       String name = pic.getName();

       String date = pic.getDate();

      

       // displaying the value fetched from get method

       // value will be name - flower_pic and date - 28-04-2020

       System.out.println("[ Name of the Picture - "+name+" and Date - "+date+" ]");

      

       // now we will use set method to set the value of name and date and then display that value

       // declaring two variable

      

       String name1 = "tiger_pic";

       String date1 = "28-03-2020";

      

       //assigning those value using set method

      

       pic.setName(name1);

       pic.setDate(date1);

      

       System.out.println("[ Name of the Picture - "+pic.getName()+" and Date - "+pic.getDate()+" ]");

      

   }

}