Question: Requirements When the application starts, it will automatically populate the Student Roster list box, but nothing else works. Your task is to complete the following:

Requirements
When the application starts, it will automatically populate the "Student Roster" list box, but nothing else works. Your task is to complete the following:
Record Attendance Button
When the application starts, the "Record Attendance" button is disabled, as seen at the beginning of the video.
The button should only be enabled (and therefore clickable) when the text in "Student Email" exactly matches an email address from the roster. That is if the text in "Student Email" is not the same as one of the roster items, the button should stay disabled. This check should be performed using the ON_CHANGE event of the "Student Email" input.
Clicking the button should record the attendance of the student whose email is written in the input, and update the counter.
You are free to make other UI/UX (User Interface/User Experience) enhancements, if you wish.
Student Roster Listbox Filtering
A required UX enhancement is for the "Student Roster" list box to dynamically update its contents as the user types in the "Student Email" input.
The "Student Roster" list box should contain only those emails that begin with the same sequence of characters as what is typed in the "Student Email" input.
Example
Student Roster contents:
bryce@ucmerced.edu
alice@ucmerced.edu
bill@ucmerced.edu
jerry@ucmerced.edu
brian@ucmerced.edu
Case 1
Student Email contents: "b", then Student Roster is:
bryce@ucmerced.edu
bill@ucmerced.edu
brian@ucmerced.edu
because these are the only ones that start with "b".
Case 2
Student Email contents: "br", then Student Roster is:
bryce@ucmerced.edu
brian@ucmerced.edu
because these are the only ones that start with "br".
Case 3
Student Email input box in empty, then Student Roster is:
bryce@ucmerced.edu
alice@ucmerced.edu
bill@ucmerced.edu
jerry@ucmerced.edu
brian@ucmerced.edu
because there is no string to filter by, so we include everything.
Record Attendance Duplication
As described above, once a matching email is found in the Student Roster, the "Record Attendance" button should be activated. The application must prevent the user from recording attendance for the same student more than once.
Hints :This program uses a container called a vector (line 20). A vector is a special type of variable in C++ that can be used to store more than 1 value. The particular vector on line 20 is a vector of string, meaning that it can store multiple string values, unlike a regular string variable that can hold only one.
A vector of string is similar to a ListBox component in Bobcat UI, as they both store collections of string values. Consequently, the contents of a ListBox can be derived from a vector. Line 51 in the code sets the values of the vector, and the populateRosterList function on lines 40-44, uses the contents of the vector to populate the ListBox.
A ListBox can be cleared by calling a ->clear() function on it. If we then have a vector of string values, we can use code similar to the populateRosterList function to fill up the ListBox with content.
This is useful for filtering applications. Suppose we have a vector of strings, and it has hundreds of values. We can create another vector and make it start out empty. The C++ code for that is:
std::vector filteredList;
This creates an empty vector called filteredList. We can add values to this empty vector by saying:
filteredList.push_back(...);
where the ... is some string value.
If we had a filteredList like that, we could make the contents of the "Student Roster" list box to be the filteredList, not the roster vector.
To create such a list, what we would need to do is go through the roster vector, and for every item inside it, check if it starts with the text from the "Student Email" input box. If it does, then add it to the filteredList.
The way to check if a word starts with a given sequence of characters is to use the startsWith function, on lines 30-37.
This is a function that takes in two string values big and small, and checks if big starts with the sequence of characters written in small.
Examples
startsWith("brian","br"); //=> truestartsWith("hello","br"); //=> falsestartsWith("hello","he"); //=> truestartsWith("hello","el"); //=> false
std::vectorstd::string roster;
// components
ListBox* rosterList;
ListBox* attendanceRecordList;
Input* emailInput;
ReturnButton* recordAttendanceButton;
TextBox* attendanceCountText;
// check if string string (big) starts with a substring (small)
bool startsWith(std::string big, std::string small){
for (int i =0; i small.length(); i++){
if (toupper(c: big[i])!= toupper(c: small[i])){
return false;
}
return true;
}
// populate rosterList using roster vector data
void populateRosterList()
for (int i =0; i roster.size(); i++){
rosterList->add(text: roster[i]);
}
public
Application()
theme();
// initializing state variables
attendanceCount =0;
// initializing components
window = new Window(x:100, y:100, w:400, h:400, title: "Attendance Recorder
Attendance Recorder
Studen
Requirements When the application starts, it will

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!