How to define the getPrice method in this subclass?

How to define the getPrice method in this subclass?



I am trying to determine how I should define the getPrice method. The shirts can range from Small to XXXL and the price varies. The price is determined by the size: $22.99 for XXL or XXXL, and $19.99 for all other sizes.



There are two other classes that I have complied. But the method I need help with only goes with this code.


public class TeeShirt
private int orderNumber;
private String size;
private String color;
private double price;
public void setOrderNumber(int num)
orderNumber = num;

public void setSize(String sz)
size = sz;

public void setColor(String color)
this.color = color;

public int getOrderNumber()
return orderNumber;

public String getSize()
return size;

public String getColor()
return color;

public double getPrice()
return price;

//end






What's the problem?

– shmosel
Sep 18 '18 at 3:25






Java is to Javascript as Pain is to Painting, or Ham is to Hampster. They are completely different. It is highly recommended that aspiring coders try to learn the name of the language they're attempting to write code in. When you post a question, please tag it appropriately.

– CertainPerformance
Sep 18 '18 at 3:26






@CertainPerformance Unless someone takes it upon himself to eat hampsters :-)

– Tim Biegeleisen
Sep 18 '18 at 3:26






What's a hampster?

– shmosel
Sep 18 '18 at 3:28






And where are you stuck?

– shmosel
Sep 18 '18 at 3:35




1 Answer
1



You could assign the price on your setSize() function depending on size type.


setSize()


public void setSize(String sz)
size = sz;
if(size.equals("XXXL")






That works! Thank you!

– Nylah.
Sep 18 '18 at 3:43



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế