Question

In: Computer Science

1.) According to the UML Class Diagram, these are the mutator and accessor methods that you...

1.) According to the UML Class Diagram, these are the mutator and accessor methods that you need to define:

1a.) +setName(value:String):void

1b.) +setGPA(value:double):void

1c.) +setID(value: String):void

1d.) +getName(): String

1e.) +getLastName():String

2.) Working with constructors

2a.) +Student() : This is the default constuctor. For the Strings properties, initialize them to null. The order is String ID, String name, String lastName, and double GPA.

2b.) +Student(value:String) - This constructor receives just the ID.

2c.) +Student(value:String, var: String) - This constructor receives the ID and name in that order.

2d.) +Student(value:String, var: String, change: String) - This constructor receives the ID, name, and last name in that order.

Solutions

Expert Solution

implementation:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication23;
import java.util.Random;
import java.util.Scanner;

/**
 *
 * @author haptop laptop
 */
class Student{
    String name;
    String id;
    String lastName;
    double GPA;
    
Student()//2.a solution//default constructor
{
    id=null;
    name=null;
    lastName=null;
    GPA=0.0;
    
    
    
}
Student(String value)//2.b solution//parametrized constructor
{
    id=value;
}
Student(String value,String var)//2.c solution//parametrized constructor
{
    id=value;
    name=var;
    
}
Student(String value,String var,String change)//2.d solution//parametrized constructor
{
    id=value;
    name=var;
    lastName=change;
}
void setName(String value )//sol 1.a//mutator method
{
    name=value;
}
void setGPA(double value)//sol 1.b//mutator method
{
    GPA=value;
}
void setId(String value)//sol 1.c//mutator method
{
    id=value;
}
String getName()//sol 1.d//accessor method 
{
 return name;    
}
String getLastName()//sol 1.e//accessor method 
{
    return lastName;
}
double getGPA()//accessor method 
{    return GPA;
}
}
        



public class JavaApplication23 {

    /**
     * @param args the command line arguments
     */
    
  
    public static void main(String[] args) {
        // TODO code application logic here
       Student s1=new Student();//object
       Student s2=new Student("shreya");//object
       Student s3=new Student("sristy","1234");
       Student s4=new Student("1232","shresth","sharma");
       System.out.println("name of student "+s4.getName()+" last name is "+s4.getLastName());
       s1.setName("john");
       s1.setGPA(4.5);
       System.out.println("name of student "+s1.getName()+" gpa is "+s1.getGPA());
   

// TODO Auto-generated method stub

    }
}

//hope it is cleared i have mentioned details in the comment of program.


Related Solutions

1: (Passing Objects to Methods) From the following UML Class Diagram, define the Circle class in...
1: (Passing Objects to Methods) From the following UML Class Diagram, define the Circle class in Java. Circle Circle Radius: double Circle() Circle(newRadius: double) getArea(): double setRadius(newRadius: double): void getRadius(): double After creating the Circle class, you should test this class from the main() method by passing objects of this class to a method “ public static void printAreas(Circle c, int times)” You should display the area of the circle object 5 times with different radii.
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram...
create the UML Diagram to model a Movie/TV viewing site. Draw a complete UML class diagram which shows: Classes (Only the ones listed in bold below) Attributes in classes (remember to indicate privacy level, and type) No need to write methods Relationships between classes (has is, is a, ...) Use a program like Lucid Cart and then upload your diagram. Each movie has: name, description, length, list of actors, list of prequals and sequals Each TV Show has: name, description,...
Draw a UML diagram for the classes. Code for UML: // Date.java public class Date {...
Draw a UML diagram for the classes. Code for UML: // Date.java public class Date {       public int month;    public int day;    public int year;    public Date(int month, int day, int year) {    this.month = month;    this.day = day;    this.year = year;    }       public Date() {    this.month = 0;    this.day = 0;    this.year = 0;    } } //end of Date.java // Name.java public class Name...
Draw a UML diagram that describes a class that will be used to describe a product...
Draw a UML diagram that describes a class that will be used to describe a product for sale on Glamazon.com. The product has a name, a description, a price, ratings by many customers (1 to 5 stars), and a group of customer comments. New products have no ratings or comments by customers, but do have a name, description and price. The price can be changed and more customer ratings and comments can be added. A global average rating of all...
For this assignment, create a complete UML class diagram of this program. You can use Lucidchart...
For this assignment, create a complete UML class diagram of this program. You can use Lucidchart or another diagramming tool. If you can’t find a diagramming tool, you can hand draw the diagram but make sure it is legible. Points to remember: • Include all classes on your diagram. There are nine of them. • Include all the properties and methods on your diagram. • Include the access modifiers on the diagram. + for public, - for private, ~ for...
Complete the following class UML design class diagram by filling in all the sections based on...
Complete the following class UML design class diagram by filling in all the sections based on the information given below.         The class name is Boat, and it is a concrete entity class. All three attributes are private strings with initial null values. The attribute boat identifier has the property of “key.” The other attributes are the manufacturer of the boat and the model of the boat. Provide at least two methods for this class. Class Name: Attribute Names: Method...
What would the pseudocode look like for this UML class diagram? Class - oranges: String -...
What would the pseudocode look like for this UML class diagram? Class - oranges: String - bananas: String - grapes: String - apples: String + Class(String bananas, String grapes, String apples) + oranges( ): void + isValidGrapes( ): boolean + isValidApples( ): boolean + getOranges( ): String + getBananas( ): String + setBananas(String bananas): void + getGrapes( ): String + setGrapes(String grapes): void + getApples( ): String + setApples(String apples): void
HW 8-1a   1.)   Referring to the UML class diagram, create a program that utilizes the Student...
HW 8-1a   1.)   Referring to the UML class diagram, create a program that utilizes the Student class. - id : Integer - units : Integer - name : String + Student ( ) : + Student (id : Int, name : String, units : Int) : + ~Student( ) : + setID(id : Integer) : void + setName(name: String) : void + setUnits(units : Integer ) : void + displayRecord() : void 2.)   Include 3 files: -   Source.cpp -   Student.h...
A UML class diagram has the following description about a member of the class: + getHeaderField(name:String):String...
A UML class diagram has the following description about a member of the class: + getHeaderField(name:String):String Which of the following is a correct declaration of the member in Java? 1 public String getHeaderField(String name) 2 public String getHeaderField; 3 public String getHeaderField(String) 4 public static String getHeaderField( name) ------------------------------------------------------------------------------------------------------------------------------------- Note: all answers are case sensitive. Inside a class, the declaration of a constructor looks like the following: public JButton(String text) 1. From the constructor, you infer that the name of...
Java Write a Payroll class as demonstrated in the following UML diagram. Member variables of the...
Java Write a Payroll class as demonstrated in the following UML diagram. Member variables of the class are: NUM_EMPLOYEES: a constant integer variable to hold the number of employees. employeeId. An array of integers to hold employee identification numbers. hours. An array of integers to hold the number of hours worked by each employee payRate. An array of doubles to hold each employee’s hourly pay rate wages. An array of seven doubles to hold each employee’s gross wages The class...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT