Question
Just started making classes in java and i have been set this task - non graded Just need some help as i am a little
Just started making classes in java and i have been set this task - non graded
Just need some help as i am a little confused on the overall concept - in java on intellij - Thanks
Task 2
Modify the program developed in Task 1 as directed below.
Extend the definition of the class Boat to include a constructor with the following formal parameters:
the_name of type String
the_bClass of type String
the_regNum of type int The constructor should assign each of the classs instance variables to the respective formal parameter. For example, regNum should be assigned to the value of the_regNum. For example, new Boat("Harmony Blue","International 505",6467); constructs a new Boat object. Note that
constructors do not have a return type and
defining your own constructor, effectively undefines the default constructor (Boat()).
Extend the definition of the class Boat to include a default constructor, namely, Boat() {}
Modify the main method in the definition of the class BoatMaker to perform only the following:
Print the message Starting boat application
Define a variable called myBoat1 of type Boat and initialise it to a new Boat object using the default constructor (as in Task 1).
Define a variable called myBoat2 of type Boat and initialise it to a new Boat object constructed with the actual parameters "Harmony Blue", "International 505" and 6467
Invoke (call) the print method from myBoat1
Invoke (call) the print method from myBoat2
Run the application from IntelliJ . The following output should be produced: Starting boat application Boat unknown, Class = unknown, Registration # = KA -1 Boat Harmony Blue, Class = International 505, Registration # = KA 6467
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