Question & Answer: Write the code from UML diagrams for these 2 questions…..

Write the code from UML diagrams for these 2 questions

1)

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: Write the code from UML diagrams for these 2 questions…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Write the code for the Name and Student classes. In both cases, the constructor should initialize the object based on the parameters and the toString should return the contents separated by a blank. The updateGRA should change the gpa based on the parameter. Name Student name: Name firstString last String pa: double + Student (String, String, double) +toString 0: String +updateGPA (double) void + Name (String, String) +t tostring O: String

2)

Question & Answer: Write the code from UML diagrams for these 2 questions..... 1

Expert Answer

 1) Following is the required program for above mentioned problem. The code’s been compiled and run in Eclipse IDE and is a genuine piece of work.

The code BEGINS from here:

/*
* Class Name
*/
public class Name {
private String first;
private String last;

// Constructor
public Name(String fName, String lName){
first = fName;
last = lName;
}

// toString Method
public String toString(){
return (first + ” ” + last);
}

}

/*
* Student Class
*/

public class Student {
public Name name;
private double gpa;

// Constructor
public Student(String fName, String lName, double gp){
name = new Name(fName, lName);
gpa = gp;
}

// updateGPA Method
public void updateGPA(double gp){
    // Your code to change the gpa here
}

// toString Method
public String toString(){
return (name.toString() + “: ” + gpa);
}
}

**************** DemoClass.java*********************

public class DemoClass {
public static void main(String[] args) {
Student stu = new Student(“Shadow”, “Blade”, 9.5);
System.out.println(stu.toString());
}
}

Note: The main class is just for a demo.

ScreenShot:

Question & Answer: Write the code from UML diagrams for these 2 questions..... 2

Hope this code meets all your requirements…

Still stressed from student homework?
Get quality assistance from academic writers!