473,614 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help


Please help, I am learning java and have been stuck with this problem. I
have been trying to
figure it out on my own, but I am getting nowhere. The problem is this; I
need to create a class
named shirt with three data fields. I need a constructor that will take
arguments for the sleeve and
collar fields.I need to be able to use this to create three shirt objects. I
am stuck and I dont want
anyone to do my work for me, just a push in the right direction. Thank you
for your time. Mike

class shirt
{
int sleeve;
int collar;
double min = 200.00;

public static getsleeve()
{
return sleeve;
}

public static getcollar()
{
return collar
}

{

public class newshirt
{
public static void main(String[] args)
{
shirt myshirt = newshirt(12, 20);

//This is were I need help how can i use access the values (12, 20)
Jul 17 '05 #1
2 1720
Hi Mike,

A few tips:
1) Don't try to stuff everything into one class.
Create a class Shirt and use that one from your main.

2) Do not use the static-keyword unless you know what is does.
I guess you introduced static in your methods to keep your compiler happy.

So what you should do is first create a nice Shirt class.
To pass the attributes of a shirt to the shirtclass you have a few options:
a) pass them to the constructor, (from main:)
Shirt myFirstShirt = new Shirt(10,20,30) ;
Shirt mySecondShirt = new Shirt(2,2,1);

or b) Create an empty Shirt-object and create a few methods to set the
attributes of your shirt, like this:
Shirt myFirstShirt = new Shirt();
myFirstShirt.se tCollarSize(20) ;
myFirstShirt.se tSize("Large");

This is just fantasycode of course, but I hope it helps you a bit.

Good luck,
Erwin

Jul 17 '05 #2
Also,
If you use the constructor version shown in (a) below, your Shirt Class
will need a Shirt Constructor method....
eg
public Shirt(int pSleeve, int pCollar) {
sleeve = pSleeve;
collar = pCollar;
}
Then to access the values for sleeve and collar you would use the
MyShirt.getslee ve(), and MyShirt.getcoll ar() methids.

Hope this helps :)
erwin moller wrote:
Hi Mike,

A few tips:
1) Don't try to stuff everything into one class.
Create a class Shirt and use that one from your main.

2) Do not use the static-keyword unless you know what is does.
I guess you introduced static in your methods to keep your compiler happy.

So what you should do is first create a nice Shirt class.
To pass the attributes of a shirt to the shirtclass you have a few options:
a) pass them to the constructor, (from main:)
Shirt myFirstShirt = new Shirt(10,20,30) ;
Shirt mySecondShirt = new Shirt(2,2,1);

or b) Create an empty Shirt-object and create a few methods to set the
attributes of your shirt, like this:
Shirt myFirstShirt = new Shirt();
myFirstShirt.se tCollarSize(20) ;
myFirstShirt.se tSize("Large");

This is just fantasycode of course, but I hope it helps you a bit.

Good luck,
Erwin


Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1693
by: Kurt Watson | last post by:
I’m having a different kind of problem with Hotmail when I sign in it says, "Web Browser Software Limitations Your Current Software Will Limit Your Ability to Use Hotmail You are using a web browser that Hotmail does not support. If you continue to use your current browser software we cannot guarantee that Hotmail will work correctly for you". Please help, this is very annoying. I have been searching for help on
7
3592
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title> </head> <style type="text/css">
7
3276
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that I believe if it's solved, the remaining stuff is easy... my full program until now is here: http://www.geocities.com/tom4_h4wk/progmail.zip the problem is the segmentation fault when main trys to run leficheiro.c.... the *.c2 files are the...
23
3258
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
13
4316
by: Joner | last post by:
Hello, I'm having trouble with a little programme of mine where I connect to an access database. It seems to connect fine, and disconnect fine, but then after it won't reconnect, I get the error "operation is not allowed when object is open" so I take out the line of code: BookDetails.Connection1.Open and it comes up with the error "operation is not allowed when object
1
9622
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
1
54492
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
0
3043
by: 2Barter.net | last post by:
newsmail@reuters.uk.ed10.net Fwd: Money for New Orleans, AL & GA Inbox Reply Reply to all Forward Print Add 2Barter.net to Contacts list Delete this message Report phishing Show original
6
3309
by: jenipriya | last post by:
Hi all... its very urgent.. please........i m a beginner in oracle.... Anyone please help me wit dese codes i hv tried... and correct the errors... The table structures i hav Employee (EmpID, EmpName,DeptID,DateOfJoin, Sal, Addr) Finance (EmpID, Sal) Club (Clubname, EmpID, Fee, DateOfJoin) Leave (EmpID, Date) Department (DeptID, DeptName, NoOfEmployees)...
5
2301
by: tabani | last post by:
I wrote the program and its not giving me correct answer can any one help me with that please and specify my mistake please it will be highly appreciable... The error arrives from option 'a' it asks for user name, check in the system but does not return the correct answer please help me with it. or if you have better way of doing it would you please mind to tell me.. thanks.. #!/usr/bin/perl -w #use Getopt::Std;
0
8176
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8571
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8265
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8423
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7047
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4048
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2560
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1705
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.