This is the first exercise for the TODO comments in the main method. Complete the actions described in these comment lines in the main method: // TODO: Add a public static constant called PRIMARY_NAME // to the Student class. Set the name of the Primary to // a real University. In other words:                                                                                                                  Add a public static final String variable called PRIMARY_NAME to the fields of the Student class. Initialise the variable in the same line it is declared (not in the constructor) to the name of a real Primary. Add code to the Main class in this project to access the PRIMARY_NAME field and print it out. Remember that, because the field is public, it can be accessed directly from another class without having to provide a getter method for it. In the lecture discussing static fields and methods, we showed that the nextID field in the Student class is used to store the value of the next student ID to be allocated as each Student is created.This and the following exercises will confirm this behaviour. Complete the actions described in these comment lines in the main method: // Get the number of the next Student id to be allocated // and store it in a local variable. // TODO: Your code here to set nextID. int nextID; In other words, set the nextID local variable in the main method by calling the getter for the nextID field in the Student class. Remember that the getter is a static method, so it must be called on the Student class name rather than on a Student object. Complete the actions described in these comment lines in the main method: // TODO: Your code here to set studentID to the ID // of aStudent. int studentID; In other words, set the studentID local variable by calling the ID getter method on the aStudent Student object. Complete the actions described in these comment lines in the main method: // TODO: Write an if-statement to check that the student just // created has the same ID as that stored in nextID. // Print OK if they have the correct ID. // Print Error if they do not have the correct ID.                                                                                                  If other words, compare the values of the nextID and studentID local variables in the main method to make sure they are the same. Print OK if they are or Error if they are not. Complete the actions described in these comment lines in the main method: // TODO: Repeat the above steps to: // + get the nextID to be allocated. //       + create a second Student object. //       + get the ID of the second Student object. //       + check and report whether the IDs match.                                                                                              In other words, get the nextID again from the Student class and store it in the nextID local variable in the main method. Create a second Student object and store it in the aStudent variable. Get the ID of aStudent and store it in the studentID local variable. Compare the values of nextID and StudentID and print either OK or Error.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is the first exercise for the TODO comments in the main method. Complete the actions described in these comment lines in the main method:
// TODO: Add a public static constant called PRIMARY_NAME
// to the Student class. Set the name of the Primary to
// a real University. In other words:                                                                                                                  Add a public static final String variable called PRIMARY_NAME to the fields of the Student class. Initialise the variable in the same line it is declared (not in the constructor) to the name of a real Primary. Add code to the Main class in this project to access the PRIMARY_NAME field and print it out. Remember that, because the field is public, it can be accessed directly from another class without having to provide a getter method for it. In the lecture discussing static fields and methods, we showed that the nextID field in the Student class is used to store the value of the next student ID to be allocated as each Student is created.This and the following exercises will confirm this behaviour. Complete the actions described in these comment lines in the main method:

// Get the number of the next Student id to be allocated
// and store it in a local variable.
// TODO: Your code here to set nextID.
int nextID; In other words, set the nextID local variable in the main method by calling the getter for the nextID field in the Student class. Remember that the getter is a static method, so it must be called on the Student class name rather than on a Student object. Complete the actions described in these comment lines in the main method:

// TODO: Your code here to set studentID to the ID
// of aStudent.
int studentID; In other words, set the studentID local variable by calling the ID getter method on the aStudent Student object. Complete the actions described in these comment lines in the main method:

// TODO: Write an if-statement to check that the student just
// created has the same ID as that stored in nextID.
// Print OK if they have the correct ID.
// Print Error if they do not have the correct ID.                                                                                                  If other words, compare the values of the nextID and studentID local variables in the main method to make sure they are the same. Print OK if they are or Error if they are not. Complete the actions described in these comment lines in the main method:

// TODO: Repeat the above steps to:
// + get the nextID to be allocated.
//       + create a second Student object.
//       + get the ID of the second Student object.
//       + check and report whether the IDs match.                                                                                              In other words, get the nextID again from the Student class and store it in the nextID local variable in the main method. Create a second Student object and store it in the aStudent variable. Get the ID of aStudent and store it in the studentID local variable. Compare the values of nextID and StudentID and print either OK or Error.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education