Question: Deliverables app.java (initial application) MainFrame.java (external JFrame) A Java class for the control panel, that will contain the 2 new panels, using a layout. A

Deliverables

app.java (initial application)

MainFrame.java (external JFrame)

A Java class for the control panel, that will contain the 2 new panels, using a layout.

A Java class for the Panel that will display the groups name and group's average GPA

A Java class for the Panel that will display names and semester GPAs of the 4 students in a group.

group.java and student.java (a working version from previous labs, no changes needed).

Students should apply consistent indenting in all submissions. This can be done via the NetBeans Source menu.

Contents

You will start with a working version from the previous lab. All requirements are still the same including "You will create only one group object g1 in this assignment. There will be only one statement group g1 = new group(...); in the whole application."

Additional requirements are below.

You will be listening to the 4 buttons with student information. Every time a user click on one of the buttons, the GPA will be recalculated using semesterGPA and displayed again.

When a student GPA is recalculated, the group average GPA has to be updated too and displayed again.

Important - #1 - Where to implement the ActionListener?

It is a requirement that you implement the ActionListener in ControlPanel, which is the panel that contains the other two panels.

You have to use the traditional model for listening that you have been using so far

public class ControlPanel extends JPanel implements ActionListener

Lab 06 Listening: (no audio/transcript)(0:20) (Links to an external site.)Links to an external site.

package inheritance;

import java.util.Random;

// Creates a base class Person

class Person

{

// Instance variable to store person data

String firstName;

String lastName;

int age;

String homeTown;

// Default constructor to initialize instance variables

Person()

{

firstName = lastName = homeTown = "";

age = 0;

}// End of default constructor

// Parameterized constructor to assign parameter value to instance variables

Person(String fn, String ln, int ag, String ht)

{

firstName = fn;

lastName = ln;

homeTown = ht;

age = ag;

}// End of parameterized constructor

// Method to return first name

String getFirstName()

{

return firstName;

}// End of method

// Method to return last name

String getLastName()

{

return lastName;

}// End of method

// Method to return home town

String getHomeTown()

{

return homeTown;

}// End of method

// Method to return age

int getAge()

{

return age;

}// End of method

// Method to return person information in string format

String getInfo()

{

return " Name " + firstName + " " + lastName + " Home Town: " + homeTown + " Age: " + age;

}// End of method

}// End of class Person

// Creates a class Student derived from Person

class Student extends Person

{

// Instance variable to store student data

String ID;

String major;

double gpa;

// Default constructor to initialize instance variables

Student()

{

// Calls the base class default constructor

super();

ID = major = "";

gpa = 0;

}// End of default constructor

// Parameterized constructor to assign parameter value to instance variables

Student(String fn, String ln, int ag, String ht, String id, String ma, double gp)

{

// Calls the base class parameterized constructor

super(fn, ln, ag, ht);

ID = id;

major = ma;

gpa = gp;

}// End of parameterized constructor

// Method to return id

String getID()

{

return ID;

}// End of method

// Method to return major

String getMajor()

{

return major;

}// End of method

// Method to return gpa

double getGPA()

{

return gpa;

}// End of method

// Overrides base class method to return student information in string format

String getInfo()

{

// Concatenates base class getInfo() return string with own class member information

return super.getInfo() + " ID: " + ID + " Major: " + major + " GPA: " + gpa;

}// End of method

}// End of class Student

//Creates a class student_athlete derived from Student

class student_athlete extends Student

{

// Instance variable to store student_athlete data

String sports;

int rank;

// Default constructor to initialize instance variables

student_athlete()

{

// Calls the base class default constructor

super();

sports = "";

rank = 0;

}// End of default constructor

// Parameterized constructor to assign parameter value to instance variables

student_athlete(String fn, String ln, int ag, String ht, String id, String ma, double gp, String sp, int ra)

{

// Calls the base class parameterized constructor

super(fn, ln, ag, ht, id, ma, gp);

sports = sp;

rank = ra;

}// End of parameterized constructor

// Method to return sports

String getSports()

{

return sports;

}// End of parameterized constructor

// Method to return rank

int getRank()

{

return rank;

}// End of method

// Overrides base class method to return student_athlete information in string format

String getInfo()

{

// Concatenates base class getInfo() return string with own class member information

return super.getInfo() + " Sports: " + sports + " Rank: " + rank;

}// End of method

}// End of class student_athlete

// Driver class App definition

public class App

{

// main method definition

public static void main(String[] args)

{

// Creates a random class object

Random rn = new Random();

// Declares an array of objects of class student_athlete of size 3

student_athlete st[] = new student_athlete[3];

// Dynamically creates objects using parameterized constructor

st[0] = new student_athlete("Pyari", "Sahu", 22, "BAM", "111", "Java", 9.6, "Cricket", rn.nextInt(100));

st[1] = new student_athlete("Suresh", "Panda", 42, "BBSR", "222", "C", 3.2, "Football", rn.nextInt(100));

st[2] = new student_athlete("Anita", "Swain", 34, "RKL", "333", "C++", 6.1, "Volleyball", rn.nextInt(100));

// Loops three time to display information by calling getInfo() method

for(int x = 0; x

System.out.println(st[x].getInfo());

}// End of main method

}// End of driver class App

Sample Output:

Name Pyari Sahu Home Town: BAM Age: 22 ID: 111 Major: Java GPA: 9.6 Sports: Cricket Rank: 7

Name Suresh Panda Home Town: BBSR Age: 42 ID: 222 Major: C GPA: 3.2 Sports: Football Rank: 38

Name Anita Swain Home Town: RKL Age: 34 ID: 333 Major: C++ GPA: 6.1 Sports: Volleyball Rank: 98

The ActionListener will be implemented in the ControlPanel, the external panel that contains the other two panels. A container panel with a border layout. It has two panels. The ActionListener will be implemented here. Nittany Lions group average GPA is 2.53 You will listen to this button and A panel with 3 buttons displaying information extracted from a group object. Uses the default layout. NAME- Zack Smith 2.65 when it is clicked it will recalculate and display the GPA again. You will listen to this button and NAME Robert Jones 3.44 when it is clicked it will recalculate A panel with 4 buttons with group student's names and with student's semester GPAs extracted from a group object. Uses a grid layout. The 4 buttons will be listened to and they will display the recalculated GPA when they are clicked. and display the GPA again. You will listen to this button and NAME - Jennifer Morris 2.0 when it is clicked it will recalculate and display the GPA again. You will listen to this button and when it is clicked it will recalculate and display the GPA again. NAME Megan Hilton 2.03 The ActionListener will be implemented in the ControlPanel, the external panel that contains the other two panels. A container panel with a border layout. It has two panels. The ActionListener will be implemented here. Nittany Lions group average GPA is 2.53 You will listen to this button and A panel with 3 buttons displaying information extracted from a group object. Uses the default layout. NAME- Zack Smith 2.65 when it is clicked it will recalculate and display the GPA again. You will listen to this button and NAME Robert Jones 3.44 when it is clicked it will recalculate A panel with 4 buttons with group student's names and with student's semester GPAs extracted from a group object. Uses a grid layout. The 4 buttons will be listened to and they will display the recalculated GPA when they are clicked. and display the GPA again. You will listen to this button and NAME - Jennifer Morris 2.0 when it is clicked it will recalculate and display the GPA again. You will listen to this button and when it is clicked it will recalculate and display the GPA again. NAME Megan Hilton 2.03

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 Databases Questions!