Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6.2 Question 2 Create a package named Q2. Consider the UML class diagram below. In your opened Java package, write/define two classes: The first class

image text in transcribed
image text in transcribed
image text in transcribed
6.2 Question 2 Create a package named Q2. Consider the UML class diagram below. In your opened Java package, write/define two classes: The first class is called Student and has the following specifications: Student -studentNumber: int -firstName: String -lastName: String -emailAddress: String -yearOfBirth: int Studenti) +Student(sn: int, fName: String, IName: String) +setEmail(em: String): void +setYearOfBirth(yb: int): void +getStudentNumber(): int +getName(): String +getEmailAddress(): String +getAge(): int Hint: make sure you know what +- and other signs mean in a UML diagram and implement accordingly. Page 8 of 12 Specifications for the Student Class The constructor without argument will assign all field values based on the information pertaining to yourself The constructor with parameter should accept the student's number, first name and last name as arguments, and assign these values to the fields student Number, firstName and lastName. The constructor should also assign empty string to the emailAddres field and 0 to the yearOfBirth field. The accessor/setter methods will ser the values for the fields emailAddress and yearOfBirth, by accepting those values from the user. The mutator/getter method getName() returns the student's full name (the first name followed by a space followed by the last name). The mutator/getter method getNumber() should return the student's number, and getEmail should return the student's email address. The mutator/getter method getAge() calculates and returns the student's age based on the current year value, which is 2021. (c.g., if the student's year of birth is 2020, this method should return 1) Specifications for the Driver Class: In the same Java package, create a new driver class with the name StudentDemoClass Your FirstName. If your first name is Quazi, the name of this class should be Student DemoClassQuazi. This class will contain three public-static methods: your driver method, and header and footer methods you have defined earlier. From Inside the driver method do the following a Call your header method and print the required info. b. Declare a Student type reference variable and instantiate it to create an object with the help of the constructor without argument. Using the printf() method, print the information of the above student object (see the sample output) d. Now using the data shown in the table below declare three more Student type reference variables and instantiate the corresponding reference objects. In this case, i. The Constructor with argument will initialize the values for the fields student Number, firstName, and lastName. ii. The mutator methods will set the values for the rest of the instance fields. c. With the printf() method (see unit 2 section 2.7 for field width etc.), the program will display the following students' information using accessors methods of the three instantiated objects you created above. The output should follow the following format shown in the sample output . Call the footer method and end the program. Page 9 of 12 Sample output. Your Full Name Lab #?, Question #? Here is my information: I am yourFirstName yourLastName Student Number: yourStudent Number Email address: yourEmail ID@uwo.ca Age: 19 Here is the info on other students: EEEEEEE Number Name Es = 250221375 Addie Slowgrave 250309716 Talia Hanscom 250136525 Valeria McCloughen Age Email Address Essen 22 aslowgrave4@thetimes.co.uk 21 thanscom1@google.es 23 vmccloughen2@chronoengine.com *** Goodbye from yourFullName ***

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions