Question: b) The code below violates the rule on encapsulation. Re-write class museumArtifact so encapsulation is preserved. Class Artifact { private String name private int fromYear

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

b) The code below violates the rule on encapsulation. Re-write class museumArtifact so encapsulation is preserved. Class Artifact \{ private String name private int fromYear public Artifact (String name, int fromYear) \{ this, name = name; this. fromYear = fromYear \} public String getName ()\{return name; \} public int getFromYear ()\{return fromYear:\} public void setName (String name)\{this, name = name; } public void setFromYear (int fromYear) \{ this, fromYear = fromYear: \} \} class museumArtifact \{ private Artifact artifact: private String catalogue: public museumArtifact (Artifact artifact, String catalogue) this. artifact = artifact; this.catalogue = catalogue; \} public Artifact getArtifact ()\{return artifact:\} public String getCatalogue ()\{return catalogue:\} \}

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 Programming Questions!