Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In most countries, personal identification information such as name and surname are considered immutable and often require legal proceedings to change. On the other
In most countries, personal identification information such as name and surname are considered immutable and often require legal proceedings to change. On the other hand, information like height, age, and weight can fluctuate and be updated more freely. Suppose you're tasked with creating a secure system that enforces these rules: 1. Name and surname are immutable once they are set. They cannot be changed without legal authorization. 2. Blood type, once recorded, should not change as it is a biological attribute. 3. Height, age, and weight are considered mutable attributes. They can change due to various reasons (like growth, aging, or diet) and thus the system should allow for updating this information. Write a Java program that: Uses Java Modifiers and Immutable Classes to protect the name, surname, and blood type from being altered. Encapsulates mutable fields such as height, age, and weight, allowing these to be changed through public methods. Uses an array of objects to manage and demonstrate changes for multiple Person instances within your program. Provide a Main class that demonstrates creating several Person objects with initial information, changing the mutable fields, and trying to change the immutable fields (which should not be allowed and demonstrate immutability). Hint: You should use Java Modifiers, Immutable Classes, Encapsulation, Array of Objects Note That: Answers without using Classes will not be evalauted.
Step by Step Solution
★★★★★
3.42 Rating (149 Votes )
There are 3 Steps involved in it
Step: 1
Below is an example Java program that meets the specified requirements The program defines an immutable class PersonInfo for name surname and blood type and a mutable class MutableAttributes for heigh...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started