Results 1 to 7 of 7
Thread: Help using set and get
- 10-07-2009, 08:11 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
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!!!
}
- 10-07-2009, 08:19 AM #2
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.
- 10-08-2009, 02:04 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 25
- Rep Power
- 0
yes, it all looks fine to me.
I am not sure how you can screw up a get/set method anyways?
- 10-08-2009, 10:45 AM #4
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:
- 10-08-2009, 11:15 AM #5
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
- 10-08-2009, 12:06 PM #6
Member
- Join Date
- Oct 2009
- Posts
- 1
- Rep Power
- 0
hi to every 0ne
- 10-09-2009, 05:20 PM #7


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks