Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3. You need to implement a program that synchronizes two arrays of data, where the arrays are updated based on each other, after the operation
3. You need to implement a program that synchronizes two arrays of data, where the arrays are updated based on each other, after the operation is complete the two arrays would have the same data. The arrays containing the copies of the data have two rows: one for a flag A or B, and the other contains the data. If the flags in both arrays are A then the data will not be copied. If the flag is in one array and B in the second, the corresponding entry will be copied to the second array, A to B. But if the flag is B the data will be copied from the second array to the first array and the flag would be set to A to indicate that the data is synchronized. a. Create a class called Data b. Define the variable that will hold an array of data as a member of the Data class c. Create two instances of the Data class and initialize their array variables with the data given below. Array X A A B A 75 70 60 5 81 75 Array Y B B A B B 75 80 10 65 15 20 d. Create a class called Synchronizer, with a static method synchronize that takes two instances of the Data class and synchronizes their data arrays. The method will update the appropriate array based on the A, B flags. Pass the instance for Array X as a first parameter and the instance for Array Y as a second. e. Create the client class to test your code f. The program should output: i. The data is now synchronized." if the arrays had different values. ii. OR The data is already synchronized." if the arrays were already identical
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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