Make sure you write a description of your new Class in the comments
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Make sure you write a description of your new Class in the comments

Assignment Q2

Create a new BlueJ project called YourFirstNameLastName-A1Q2. For example, mine would be AlexHendry-A1Q2.

Create a class called Student.

Make sure you write a description of your new Class in the comments, with your name as author and date as the last date you worked on this exercise.

 Add definitions for the following fields:

• A name field of type String

• A studentId field of type int

• A degree field of type String

• An international field of type boolean

Write a constructor for your Student class that takes two parameters - the first of type String called myName, and the second of type int called myStudentId. Set the initial values of the corresponding fields, using the constructor.

Write an accessor method called getName that returns the value of the name field.

Write a mutator method called setStudentId that takes a single parameter of type int and sets the value of the studentId field.

Work out what other accessor and mutator methods would be useful for this Class and add them. You should be able to get and set all fields in the Class.

Write a method called printDetails, which prints out all the details of a Student object. You must take into account the international status and print a line saying either that the student is international, or the student is not international.

 For example, if:

• The name field holds the value "Helen"

• The studentId field holds the value 111222

• The degree field holds the value "Bachelor of IT"

• The international field holds the value true

Then the printDetails method would print out the following:

The name of the student is Helen. The student id of the student is 111222. The degree of the student is Bachelor of IT. The student is international.

If the international field holds the value false then the printDetails method would print out the following:

The name of the student is Helen. The student id of the student is 111222. The degree of the student is Bachelor of IT. The student is not international.

Please Note: In the above examples the name, studentId , degree and whether the student is international or not (in red) will change based on the values the fields hold. However you must print the remainder of the statements exactly as in the above examples.

Hint
ComputerA class is a collection of like objects. It describes variables and defines methods (operations) that show the relationship between the objects. In JAVA everything is associated with classes and objects where each object has its attribute. This makes writing and interpreting code easier....

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.