School of Computing & Information Technology CSCI251 Advanced Programming Autumn 2021 Assignment 3 (Worth 8%) Due 11:55pm Friday 4th June 2021. (End of Week Thirteen) This assignment involves a Monitor software to monitor users’ behaviour. General notes 1. Your assignment should be carefully organised with the same kind of expectations as the previous assignments. 2. Please provide your compilation notes in README file, to detail your OS or compiler version. 3. Other than the initial command line input, the program should run without any other user input(s). User behaviour As a network infrasturcture manager, you need to monitor users’ webpage-browsing behaviour. Assume that the user’s browsing activies can be presented by a sequence of digits (say ‘‘0 1 0 1 1’’, where 0 represetns the url link youtube.com and 1 for uow.edu.au). We want to find out how many different websites (digits) the user visit before. Alternatively, we also want to know the browsing difference between two users. You are to write a Monitor software and the main function to support and demonstrate the functionality required here. Your program should compile to Monitor and run as: ./Monitor digit user • digit : A positive integer. The number of websites for one user. • user : A positive integer. The number of users we are going to monitor. Containers You are to implement two containers: • A User container for storing their browsing history (as digits). • A Pool container containing a collection of Users. 1 Digits as urls Note that in this assignment we are using digits to represent different website urls (say 0 represetns the url link youtube.com or 1 for uow.edu.au). You are to write a function Urlgeneration allows us to generate a number (from 0-9), as the users’ browsing history. This should be done as a random generation. Users This container should be used to store users’ browsing history (a collection of digits/urls). It should be a templated container class. The following methods should also be provided. • Variety: This method should determine the number of distinct digits from the user. For example, one user has the following browsing sequence: 1 2 1 3 7 8 9. In this case, this sequence has 6 different digits, so that Variety = 6. • Difference: This method should take another user to compare. The result is the element-wise difference from two users. For instance, the difference between the browsing sequence 1 2 3 and 1 4 5 is 2: 1 2 3 (vs) 1 4 5 (result:) 0 1 1 ====> 2 Pool This container should be used to store collections of users. It should be a templated container class. The following methods should be provided. • Display This method should should display all users with their digits (urls); • minimumVariety This method should determine the minimum Variety across all users; • minimumDifference This method should determine the minimum Difference across all users; Example ./Monitor 5 3 As digit = 5 and user = 3, so you should generate activities for 3 users. Each user has 5 digits to represent what they used to browse before. The display function is used to print out all users with their digits (the following sequence should be generated randomly): 2 1 2 1 3 5 => this is for the 1st user 1 1 1 3 7 => this is for the 2nd user 1 1 1 3 0 => this is for the 3rd user Note that the 1st user is with Variety = 4, 2nd user is with Variety = 3, and the 3rd user with Variety = 3. As such, we have minimumVariety = min(4,3,3) = 3; In addition, for 1st and 2nd user, we have: 1 2 1 3 5 (vs) 1 1 1 3 7 => 0 1 0 0 1 => 2 for 1st and 3rd user, we have: 1 2 1 3 5 (vs) 1 1 1 3 0 => 0 1 0 0 1 => 2 for 2nd and 3rd user, we have: 1 1 1 3 7 (vs) 1 1 1 3 0 => 0 0 0 0 1 => 1 As such, we have minimumDifference = min(2,2,1) = 1; 3
欢迎咨询51作业君