Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Aims and Objectives This laboratory has been designed to help you e learn how to define classes which are instantiated in the main method of

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Aims and Objectives This laboratory has been designed to help you e learn how to define classes which are instantiated in the main method of an application; gain further practice with defining methods which are only used within a class (object) and those which are intended to be invoked using an object reterence. Getting Started Create a directory called prac4 (in your cpl directory) and make it your current working directory All programs wil be created from scratch and so there are no files to copy. Start jGrasp and be prepared to write complete class definitions. The program will contain "boat objects. Task 1 On completion of this task you will have demonstrated the ability to construct a simple class definition containing instance variables and methods, and a class containing only a main method which creates an instance of a class (an object) and accesses instance variables, and invokes methods, through a reference to the object Use jGrasp to create a new file called BoatMaker_16.java containing two class definitions 1. Boat this class contains: i. an instance variable, regNum, of type int initialised to -1 ii. an instance variable, bClass, of type String initialised to "unknown" iii. an instance variable name of type String which is initialised to "unknown" iv. a method print which does not return a value (i.e. the return type is void), has no formal parameters and prints the boat's name, class and registration number. in the following format Boat name, Class-bClass, Registration #-KAregNum where the words in italics should be replaced with the values of the corresponding instance variables. 2. BoatMaker 16 -this class should contain a main method which performs the following actions: Aims and Objectives This laboratory has been designed to help you e learn how to define classes which are instantiated in the main method of an application; gain further practice with defining methods which are only used within a class (object) and those which are intended to be invoked using an object reterence. Getting Started Create a directory called prac4 (in your cpl directory) and make it your current working directory All programs wil be created from scratch and so there are no files to copy. Start jGrasp and be prepared to write complete class definitions. The program will contain "boat objects. Task 1 On completion of this task you will have demonstrated the ability to construct a simple class definition containing instance variables and methods, and a class containing only a main method which creates an instance of a class (an object) and accesses instance variables, and invokes methods, through a reference to the object Use jGrasp to create a new file called BoatMaker_16.java containing two class definitions 1. Boat this class contains: i. an instance variable, regNum, of type int initialised to -1 ii. an instance variable, bClass, of type String initialised to "unknown" iii. an instance variable name of type String which is initialised to "unknown" iv. a method print which does not return a value (i.e. the return type is void), has no formal parameters and prints the boat's name, class and registration number. in the following format Boat name, Class-bClass, Registration #-KAregNum where the words in italics should be replaced with the values of the corresponding instance variables. 2. BoatMaker 16 -this class should contain a main method which performs the following actions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

What is a businesss cost structure?

Answered: 1 week ago