Question: (b) The code below violates the rule on encapsulation. Re-write it so that encapsulation is preserved. Class Tyre{ private String brand private double threadDepth public

 (b) The code below violates the rule on encapsulation. Re-write it

(b) The code below violates the rule on encapsulation. Re-write it so that encapsulation is preserved. Class Tyre\{ private String brand private double threadDepth public Tyre(String brand, double tyreDepth) \{ this.brand = brand: this.threadDepth = threadDepth \} public String getBrand()(return brand; } public double getThreadDepth ()(return threadDepth; } public void setBrand(String brand)(this.brand = brand;) public void set ThreadDepth(double threadDepth) ( this.threadDepth = threadDepth; ) ) class Car \{ private Tyre carTyre; private String make: public Car(String make, Tyre tyre)( this.make = make; this.carTyre = tyre: \} public String getMake()(return make:\} public Tyre getTyre()\{return carTyre; } ) (6 marks) Total (10 marks)

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!