473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Java Illiterate - very new to this!

5
I'm new to programming and I'm trying to understand something. I have to write an additional subclass from the code below. Attributes I need to use are for a Rowboat, specifically type of material (wood, fiberglass, inflatable) and oartype (paddles, metal or wood). I then have to Include accessor methods for the new class, a tellAboutSelf method that overrides then invokes the superclass method, and a tester program that tests the class.

Can anyone help me to sort this out? I'm lost! and don't know how to proceed

// Sailboat -- a subclass of abstract class Boat that
// overrides tellAboutSelf method in superclass

public class Sailboat extends Boat
{
// additional attributes beyond those inherited from Boat
private double MaterialType;
private int noSails;
private String motorType;

// constructor
public Sailboat(String aStateRegistrationNo, double aLength,
String aManufacturer, int aYear, double aKeelDepth,
int aNoSails, String aMotorType)
{
// invoke super class constructor
super(aStateRegistrationNo, aLength, aManufacturer, aYear);

// set subclass attribute values
setKeelDepth(aKeelDepth);
setNoSails(aNoSails);
setMotorType(aMotorType);
}

// custom method overrides superclass method
public String tellAboutSelf()
{
// invokes four superclass get methods
String allDetails;
allDetails = "This is a sailboat "
+ getStateRegistrationNo() + " " // invoke Boat method
+ getLength() + " " // invoke Boat method
+ getManufacturer() + " " // invoke Boat method
+ getYear() + " " // invoke Boat method
+ keelDepth + " "
+ noSails + " "
+ motorType;
return allDetails;
}
// set accessor methods
public void setKeelDepth(double aKeelDepth)
{ keelDepth = aKeelDepth; }
public void setNoSails(int aNoSails)
{ noSails = aNoSails; }
public void setMotorType(String aMotorType)
{ motorType = aMotorType; }

// get accessor methods
public double getKeelDepth()
{ return keelDepth; }
public int getNoSails()
{ return noSails; }
public String getMotorType()
{ return motorType; }
}
Apr 23 '07 #1
1 1660
r035198x
13,262 8TB
I'm new to programming and I'm trying to understand something. I have to write an additional subclass from the code below. Attributes I need to use are for a Rowboat, specifically type of material (wood, fiberglass, inflatable) and oartype (paddles, metal or wood). I then have to Include accessor methods for the new class, a tellAboutSelf method that overrides then invokes the superclass method, and a tester program that tests the class.

Can anyone help me to sort this out? I'm lost! and don't know how to proceed

// Sailboat -- a subclass of abstract class Boat that
// overrides tellAboutSelf method in superclass

public class Sailboat extends Boat
{
// additional attributes beyond those inherited from Boat
private double MaterialType;
private int noSails;
private String motorType;

// constructor
public Sailboat(String aStateRegistrationNo, double aLength,
String aManufacturer, int aYear, double aKeelDepth,
int aNoSails, String aMotorType)
{
// invoke super class constructor
super(aStateRegistrationNo, aLength, aManufacturer, aYear);

// set subclass attribute values
setKeelDepth(aKeelDepth);
setNoSails(aNoSails);
setMotorType(aMotorType);
}

// custom method overrides superclass method
public String tellAboutSelf()
{
// invokes four superclass get methods
String allDetails;
allDetails = "This is a sailboat "
+ getStateRegistrationNo() + " " // invoke Boat method
+ getLength() + " " // invoke Boat method
+ getManufacturer() + " " // invoke Boat method
+ getYear() + " " // invoke Boat method
+ keelDepth + " "
+ noSails + " "
+ motorType;
return allDetails;
}
// set accessor methods
public void setKeelDepth(double aKeelDepth)
{ keelDepth = aKeelDepth; }
public void setNoSails(int aNoSails)
{ noSails = aNoSails; }
public void setMotorType(String aMotorType)
{ motorType = aMotorType; }

// get accessor methods
public double getKeelDepth()
{ return keelDepth; }
public int getNoSails()
{ return noSails; }
public String getMotorType()
{ return motorType; }
}
What do you think should be done? Post your own ideas/attempt first.
Apr 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
2
by: enclume42 | last post by:
Hello, I am a pure Linux guy. I wrote a Java program that is going to be used by some Windows people, and I wish the startup of the program to be as simple as possible, namely to double-click on...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
4
tpgames
by: tpgames | last post by:
I've read some tutuorials and forums giving code as to how to upload a file, but I don't need customers to my website to be able to upload anything to a java server. Am I being really dense here? ...
2
by: JoMomma | last post by:
i've been given a binary file to open and donot know what it contains except that it has floats, ints and char in it. I've built a struct to hold the data. just do not know how to read it. The first...
0
by: manikschumi | last post by:
Hi, Need some desperate help. I am trying to grab some data from a database and throw it onto my Excel sheet followed by some manipulation. Earlier I thought I can just set up a query once and then...
4
AmberJain
by: AmberJain | last post by:
I'm not a JAVA newbie..... I'm ABSOLUTE JAVA illiterate person.................. Recently, while I was planning to learn a new programming language, one of my friends advised me to learn JAVA....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.