Answered step by step
Verified Expert Solution
Link Copied!

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

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Programming questions