Create a new BlueJ project called student. From the "Edit" menu, choose "Add Class From File." Go to the "S" disk drive at the top, then go into the "Shared_Faculty_Files" folder, then go into the "Musicant" folder. Double click on the file named Student.java.
Look at the Java source code for Student.java. What does this class do?
In the top right corner of the window, click on the bar that says "Implementation". On the drop down box that appears, click "Interface". BlueJ will then automatically generate the javadoc for this class. What information does it contain? Scroll through it and look at it. Notice the detailed information it contains on author, version, and documentation for each method. How does BlueJ figure all this out? What purpose does a javadoc serve?
Click on the "Interface" bar to change it back to "Implementation".
Compile the Student class.
Create an instance of the Student class using the right click menu and the new Student() option. Then inspect the object to see the values of its attributes.
Right click the instance and use the appropriate methods to see what its idNumber, firstName, familyName and age are.
Use the appropriate method of the object to change its firstName. Don't forget to put the double quotes on the String. Inspect it to see if it worked.
Use the appropriate method of the object to change its familyName. Inspect it to see if it worked.
Use the appropriate method of the object to change its age. Inspect it to see if it worked.
Create another Student object using the right click menu and the
new Student(anIdNumber,aFirstName,aFamilyName,anAge)
option. Give the attributes some values as the object is
created. Inspect the object to see if it worked.
Create another object using the same option. See what happens when you key in the parameters incorrectly (e.g. key in the first name or the family name without quotes, or the age with quotes).
Change the familyName of this object. Then use the getFamilyName behaviour to find out what its family name is now.
From the "Edit" menu, choose "Add Class From File." Go to the "S" disk drive at the top, then go into the "Shared_Faculty_Files" folder, then go into the "Musicant" folder. Click on the file named StudentInfo.java.
Try to compile StudentInfo.java. What kind of error do you get?
to say
public String firstName;
Recompile Student, then recompile StudentInfo. StudentInfo now compiles successfully. Why? What is the difference between a private and a public data value?
Change firstName back to private in Student. Recompile.
Modify the main method in StudentInfo so that it asks a user for an idNumber, firstName, familyName, and age for three different students, each of which gets stored in an individual student object. Output a summary of each student back to the user.
void setYearManufactured(int year);You should also provide methods for obtaining these data values, namely:
void setMilesDriven(int miles);
void setManufacturerName(String name);
void setModelName(String name);
int getYearManufactured();Make appropriate use of the private and public visibility modifiers, and make sure to include a constructor.
int getMilesDriven();
String getManufacturerName();
String getModelName();
2. Check the javadoc that BlueJ generates for your class. Add comments to your program appropriately so that the javadoc contains useful information.
3. It turns out that a car might be sold to a recent immigrant from Canada. Therefore, you want to be able to report the distance driven in kilometers instead of miles. Add a method called "getKilometersDiven" that returns the distance driven in kilometers instead of miles. (Useful information: 1 mile = 1.6094 kilometers.)
Turn in both your Car class as well as another class called CarFleet. CarFleet should have a main method that asks the user for year manufactured, miles driven, manufacturer name, and model name. It should store this information appropriately in a Car object, then output the information back in a relevant manner for a Canadian customer.