Results 1 to 7 of 7
  1. #1
    LearningJava is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Default Help using set and get

    Hi,

    Anyone more advanced than me, can check this code and tell me if I use correctly the set and get to can acces to the methods?

    /**
    * @(#)AircraftQualification.java
    *
    *
    * @author: Fernando Palomar Luna
    * @version 1.00 2009/10/3
    */

    import java.util.GregorianCalendar;


    public class AircraftQualification {

    private final static int PACK_HOURS = 20;
    private final static int TRAINNING = 7;

    private String name;
    private String surname;
    private GregorianCalendar birthdate;
    private int diposit;
    private int level;
    private int aircraft;
    private int expectedDuration;
    private int experience;



    public AircraftQualification(String name, String surname, GregorianCalendar birthdate){
    this.name = name;
    this.surname = surname;
    this.birthdate = birthdate;
    this.diposit = PACK_HOURS;

    this.level = 0;

    this.aircraft = aircraft;

    this.expectedDuration = evaluateExpectedDuration();



    this.experience = 0;
    }

    public String getName(){
    return this.name;
    }

    public void setName(String name){
    this.name = name;
    }

    public String getSurname(){
    return this.surname;
    }

    public void setSurname(String surname){
    this.surname = surname;
    }

    public GregorianCalendar getBirthDate(){
    return this.birthdate;
    }

    public void setBirthdate(GregorianCalendar birthdate){
    this.birthdate = birthdate;
    }

    public int getLevel(){
    return this.level;
    }

    public int getAircraft(){
    return this.aircraft;
    }

    public int getExpectDuration(){
    return this.expectDuration;
    }

    public int getExperiencie(){
    return this.experiencie;
    }

    private void updateLevel() {

    if (this.level < 3) {
    this.level++;
    }
    else {
    System.out.println("warnning: updateLevel failed");
    }
    }

    public evaluateExpectedDuration(){

    if (this.level != 0)
    return this.birthdate.get(GregorianCalendar.MONTH) * this.level;
    }

    public void exam(){

    if (this.experience >= evaluateExpectedDuration()){
    updateLevel();
    public void setUpdateDiposit(int diposit){
    diposit = diposit - 2;
    }

    public void setUpdateExperience(int praticeHours){
    praticeHours = 0;
    }
    if (this.diposit.get(updateDiposit)<2)
    System.out.println("warnning: exam failed");
    }
    else {
    public void setUpdateDiposit(int diposit){
    diposit = diposit - 2;
    }
    }




    }


    }


    Thanks friends!!!
















    }

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Use [code] [/code] tags when posting code, but your get/set look ok. Note that using the word 'this' in your case is redundant but not incorrect.

  3. #3
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    yes, it all looks fine to me.
    I am not sure how you can screw up a get/set method anyways?

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default

    But,my question here is why u sent in constructor all the variables and assigned and separaley u are setting via setter methods?
    Ramya:cool:

  5. #5
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Quote Originally Posted by quad64bit View Post
    ... Note that using the word 'this' in your case is redundant...
    only in the getters.

  6. #6
    doctorrayray is offline Member
    Join Date
    Oct 2009
    Posts
    1
    Rep Power
    0

    Default

    hi to every 0ne

  7. #7
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Quote Originally Posted by r035198x
    only in the getters.
    Right, I forgot to specify, thanks :)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •