Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #36164
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: can someone chk is this code ok and if i can make it better please state how |
| Date | 2017-01-06 21:11 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrno7021c.pvm.avl@logic.at> (permalink) |
| References | <e69219b6-6d90-4d99-9e0c-485e867fded4@googlegroups.com> <bbd1a3d2-9f01-45b7-891a-1fe4605cc57a@googlegroups.com> |
Possible improvements:
- adding the missing close-brace for the class at the end.
- There exist styling conventions for casing (upper/lower) of
identifiers. Most of the identifiers are ok, except those
for the fields. MixedCase with an initial capital should
be used only for class-names.
- Unless "the" is part of the field name, it shouldn't be
included into accessor methods' names.
As for mutator methods: here's an example (assuming that the
fields have been renamed to lowercase initial):
...
private int weight;
...
public void setWeight(int weight)
{
this.weight = weight;
}
...
public int getWeight()
{
return weight;
}
...
ditto for the other fields.
SuperGiirl <kainattshafiq90@gmail.com> wrote:
> On Friday, January 6, 2017 at 8:38:28 PM UTC, SuperGiirl wrote:
>> public class Gadget
>> {
>> private int Weight;
>> private double Price;
>> private String Model;
>> private String Size;
>>
>>
>> public Gadget(int theWeight, double thePrice, String theModel, String theSize)
>> {
>> Weight = theWeight;
>> Price = thePrice;
>> Model = theModel;
>> Size = theSize;
>> }
>>
>>
>> public int getTheWeight()
>> {
>>
>> return Weight;
>> }
>> public double getThePrice()
>> {
>> return Price;
>> }
>> public String getTheModel()
>> {
>> return Model;
>> }
>> public String getTheSize()
>> {
>> return Size;
>> }
>
> can someone please explain how to do the mutator method
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
can someone chk is this code ok and if i can make it better please state how SuperGiirl <kainattshafiq90@gmail.com> - 2017-01-06 12:38 -0800
Re: can someone chk is this code ok and if i can make it better please state how SuperGiirl <kainattshafiq90@gmail.com> - 2017-01-06 12:52 -0800
Re: can someone chk is this code ok and if i can make it better please state how Andreas Leitgeb <avl@logic.at> - 2017-01-06 21:11 +0000
Re: can someone chk is this code ok and if i can make it better please state how SuperGiirl <kainattshafiq90@gmail.com> - 2017-01-06 14:02 -0800
Re: can someone chk is this code ok and if i can make it better please state how Eric Sosman <esosman@comcast-dot-net.invalid> - 2017-01-06 16:15 -0500
Re: can someone chk is this code ok and if i can make it better please state how Robert Klemme <shortcutter@googlemail.com> - 2017-01-07 14:16 +0100
Re: can someone chk is this code ok and if i can make it better please state how lewbloch@gmail.com - 2017-01-06 17:23 -0800
Re: can someone chk is this code ok and if i can make it better please state how Robert Klemme <shortcutter@googlemail.com> - 2017-01-07 14:23 +0100
Re: can someone chk is this code ok and if i can make it better please state how galt_57@hotmail.com - 2017-01-07 11:39 -0800
csiph-web