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

Given the following class called Gift... public class Gift {private String descr

ID: 3582902 • Letter: G

Question

Given the following class called Gift... public class Gift {private String description; private double price; private String occasion; private Boolean taxable; public static final double TAX_RATE = 0.05; public Cift(String d, double p, String o, Boolean t) description = d; price = p; occasion = o; taxable = t;} public void setPrice(double p) {price = p;} public void setTaxable(boolean t) {taxable = t;}} Fix the following method before adding it to the class. public void getPrioce() return price;} Fix the following method before adding it to the class. public void stttOccasion(String occasion) {occasion = occasion;}

Explanation / Answer

a)
public void getPrice()
{
   return this.price;   #as here this.price is neccessary to avoid ambiquity
}

b)
public void SetOcassion(String occasion)
{
   this.occasion = occasion;   #as here this.occasion is neccessary to avoid ambiquity between parameter           

                                             #and variable.
}

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