Explore BrainMass
Share

Attributes and Methods for Objects in Java

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I am having problems identifing the appropriate class names, attributes and methods for the following objects. I need at least 3 attributes and 3 methods for each class.

STUDENT
INSTRUCTOR
CLASS
MAJOR

For Example:

Class Name
Student

Attributes
socialSecurityNumber;
studentName;
studentDOB;

Methods
getStudentName();
getTotalStudentCount();
setStudentID(ssn, fname);

I have part of it done but im not sure where to go from there.
Thanks

public class Student {

// methods
public void setName(String name){}
public void getStudentName(){}
public void setTotalStudentCount(){}
public void getTotalStudentCount(){}
public void setSS(String ssn){}
public void getSS(){}

// attrs
String name;
String ssn;
String studentMajor;
}

© BrainMass Inc. brainmass.com October 16, 2018, 3:45 pm ad1c9bdddf
https://brainmass.com/computer-science/java/attributes-methods-objects-java-3995

Solution Preview

Yes, the relationship between the four objects are very complicated. However, there's something we should remember, students choose teacher, students take course, teachers add student, teachers teach courses, courses have info of students and teachers, major has info of students.
<br>
<br>class Student {
<br>
<br> protected Faculty[] advisor;
<br> private Course[] classes;
<br> protected String name;
<br> protected String ssn;
<br> protected String major;
<br> private int numberClasses;
<br>
<br>//methods:
<br> public String GetName()
<br> public String GetSSN()
<br> public String GetMajor()
<br> public String GetNumofClasses()
<br> public void setAdvisor(Faculty ...

Solution Summary

A java problem is targeted.

$2.19
Similar Posting

Java Class and Attribute Mixed Questions

1. Is there ever a reason to have a public attribute in a class?

2. What does it mean for a method to be overloaded?

3. Is it true or false that every class should have a toString( ) method that returns a String which is a text representation of the object. The method is not sent any actual. Is the toString( ) method overridden?

4.What is the value of s2:

String s1 = new String( "2 late 2 drop" );
String s2 = s1.substring( 3, 6 );

5. Is it true or false that the toUpperCase( ) method of the String class is a mutator?

6. When should an attribute of a class be static?

7. Is it true or false that if a method within a class is static, then the method can be called without an instance of the class?

8. What two access specifier keywords can be used to encapsulate attributes and behaviors within a class?

9. Is it true or false that inheritance creates an "is-a" relationship between classes?

View Full Posting Details