Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Instructions 1 . Start NetBeans. 1 . Update the user name in the User.properties file so that it displays your name as the author s
Instructions
Start NetBeans.
Update the user name in the User.properties file so that it displays your name as the
authors name every time you create a new java file using any of the templates
available in Netbeans. To modify the user name, follow the following steps:
a In the Tools menu, select Templates.
b In the dialog box that comes up click the Settings button.
c A new file should open up titled User.properties
d Uncomment the last line, and replace all text followed by user with your first
name and last name. The file should look like the following for a user with first
name Mir and last name Hasan.
Page of
Dept. CSIT, APSU
e In the File menu select Save. You can also click on the Save All icon to save
your files.
f Close the User.properties file by clicking the X on the tab.
Create a new project:
g In the File menu select New Project...
h A form should appear called Choose Project.
i Under Categories: make sure that Java with Maven is selected.
j Under Projects: make sure that Java Application is selected.
k Click Next
l If you get an error at this point about additional modules, mark all of the check
boxes, click Download and Activate.., and follow the instructions to install the
missing modules.
m A new form should appear called Name and Location.
n For Project Name: type YourlastnameLab
o For Project Location: click Browse... and select a location on your computer
where you want to store your lab assignments. Remember this location! You
will need it later when you upload your source file.
p For Group ID type csci
q Click Finish
rexcept with your name instead of mine:
Page of
Dept. CSIT, APSU
Build and debug the program:
s Compile and run your program by clicking on the green triangle icon.
t If a window pops up asking you to select a main class for execution, select
csci yourlastnamelab YourlastnameLab and click Select Main
Class.
u If you typed in the program correctly, after displaying a lot of messages about
downloading jar files, it should display something like the following in the
Output pane of the window:
This pane is also known as the console.
Create a Java class file for a Movie class.
a In the File menu select New File...
b Under Categories: make sure that Java is selected.
c Under File Types: make sure that Java Class is selected.
d Click Next.
e For Class Name: type Movie.
f For Package: select csciyourlastnamelab
Page of
Dept. CSIT, APSU
g Click Finish.
h A text editor window should pop up with the following source code except
with your actual name:
package csci yourlastnamelab;
@author Your Name
public class Movie
Implement the Movie class.
a Add the following private instance variables to the Movie class:
An instance variable called title of type String.
An instance variable called director of type String.
An instance variable called year of type int.
b Add the following methods to the Movie class:
A void method called initialize that takes two Strings and an int
as arguments, and uses those arguments to set the values of the title,
director, year instance variables.
A void method called display that displays the title and director of the
movie followed by the year in parentheses. For example, if the title of the
movie is Blade Runner, the director is Ridley Scott and the year is
it should display Blade Runner dir. Ridley Scott
Accessor methods getters for each instance variable.
Mutator methods setters for each instance variable.
c In the main function of your main class, remove the line that prints Hello
World to the output screen and then create a Movie object and perform the
following unit tests:
Initialize the movie object with a title, director and year of your choice,
and display it Your output might look like this:
Testing initialize and display:
Blade Runner dir. Ridley Scott
Page of
Dept. CSIT, APSU
For each instance variable use the corresponding mutator to change the
value, then use the accessor to make sure that the value changed. Your
output for getTitle and setTitle might look like this:
Testing setTitle and getTitle:
getTitle returns: Blade Runner
calling setTitle with argument: Brazil
getTitle returns: Brazil
d Run the main program to see if the tests were successful.
e Add an equals method to the Movie class that takes a Movie object as an
argument and returns true if the argument has the same title, director, and
year as the current object. Remember to use the equals method of the String
class to compare the two titles.
f Add code in your main method in your main class that performs the following
unit tests:
Create two movies with different titles, but the same director and year,
and test if they are the same using equals. Your output might look lik
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started