Consider the following partial UML class diagram for the class Student:
| Student |
|---|
| -studentID: String |
| -name: String |
| -school: String |
| +validateStudentID (s: Student):boolean |
studentID is a string that consists of a letter representing the school followed by 5 digits. The codes used for the schools in this scenario are shown below:
| School | Code | Example of student ID |
|---|---|---|
| FASC | 'A' | "A12345" refers to a student from FASC. |
| FAFB | 'B' | "B88888" refers to a student from FAFB. |
Write the code for the method validateStudentID (Student student) such that it performs validations on the parameter's student ID to ensure that:
- the format is correct (i.e. the student ID consists of a letter followed by 5 digits) and
- the letter value corresponds to the student's school.
Program: In this program, we create a class Student with three attributes - studentID(String), name(String), school(String). We create a boolean method validateStudentID(Student s) which takes a student class object as its parameter and checks if the student id is in the correct format, if it is, it returns true else return false.
To test the function we also need to assign the values to the attributes and for that we create an additional parameterized constructor in our class which assigns values to the attributes.
We also create a main() method in which we can create our class object and test our function.
Code:
public class Student {
//Class attributes
private String studentID;
private String name;
private String school;
//Constructor to initialize
public Student(String school, String name, String studentID){
this.school = school;
this.name = name;
this.studentID = studentID;
}
//Method validateStudentID
public boolean validateStudentID(Student student){
String id = this.studentID;
//The length of string studentID must be of length 6
if(id.length() < 6 || id.length() > 6){
return false;
}
//Check if id contains a letter at the start
if(!Character.isLetter(id.charAt(0))){
return false;
}
//Check if rest of characters after letter are digits
for (int i = 1; i < id.length(); i++) {
if(!Character.isDigit(id.charAt(i))){
return false;
}
}
//Check if the first letter corresponds to A or B
if(id.charAt(0) != 'A' && id.charAt(0) != 'B'){
return false;
}
else {
//If all conditions are true return true
return true;
}
}
//Main method
public static void main(String[] args) {
Student s = new Student("FASC","A","A12345");
System.out.println(s.validateStudentID(s));
}
}

![نها 46 } 47 48 49 //Main method public static void main(String[] args) { Student s = new Student ( school: EASC, name: A,](http://img.homeworklib.com/questions/6c714890-de1e-11ea-a6ab-d9c396a3aa13.png?x-oss-process=image/resize,w_560)
Output:

Consider the following partial UML class diagram for the class Student:
What this Lab Is About: Given a UML diagram, learn to design a class Learn how to define constructor, accessor, mutator and toStringOmethods, etc Learn how to create an object and call an instance method. Coding Guidelines for All ments You will be graded on this Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc) Keep identifiers to a reasonably short length. Use upper case for constants. Use title case (first letter is u case)...
Please use Umlet. Draw a UML domain model class diagram using the following notes on the classes, attributes and relationships discovered by the analyst so far: Your head analyst has been interviewing the department faculty about the course scheduler they would like to have developed. So far she has found a few classes. Your job is to create the UML Class diagram. Here is the information we have so far: Classes: • The Room class. All rooms have a building...
Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed to the constructor Methods: Accessors int getID( ) String getName( ) Class Roster: This class will implement the functionality of all roster for school. Instance Variables a final int MAX_NUM representing the maximum number of students allowed on the roster an ArrayList storing students Constructors a default constructor should initialize the list to empty strings a single parameter constructor that takes an ArrayList<Student> Both...
1) This exercise is about Inheritance (IS-A) Relationship. A) First, draw the UML diagram for class Student and class ComputerSystemsStudent which are described below. Make sure to show all the members (member variables and member functions) of the classes on your UML diagram. Save your UML diagram and also export it as a PNG. B) Second, write a program that contains the following parts. Write each class interface and implementation, in a different .h and .cpp file, respectively. a) Create...
Last picture is the tester program!
In this Assignment, you will create a Student class and a Faculty class, and assign them as subclasses of the superclass UHPerson. The details of these classes are in the UML diagram below: UHPerson - name : String - id : int + setName(String) : void + getName(): String + setID(int) : void + getID(): int + toString(): String Faculty Student - facultyList : ArrayList<Faculty - rank: String -office Hours : String - studentList...
PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...
Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....
in java language please
Question 2 (14 marks) a) Complete the following UML diagram as lava classes (8 marks): Write a constructor for Computer ser class based on the information you have in the UML Complete the hasSpaces method to check if a string has space or not il. Extend ComputerUser class with two subclasses, as shown below in UML diagram and write the appropriate methods listed in the UML diagram <<abstract>> ComputerUser # username: String #password: String + Computer...
Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...
Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...