السلام عليكم
انا جديد فى برمجه لغه الجافا ولكن املك خبره فى برمجه اللغات الاخره
واجهتنى مشكله فى الكود
اولا employee
كود:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ELGAZAR
*/
public class employee {
void doWork (){
System.out.println();
}
private String fristname;
private String lastname;
private int age;
private String addris;
String msg =("full name: "+ getFristname() +" "+ getLastname() + "Addris : "+ getAddris() + "Age: " + getAge() );
/**
* @return the fristname
*/
protected String getFristname() {
return fristname;
}
/**
* @param fristname the fristname to set
*/
protected void setFristname(String fristname) {
this.fristname = fristname;
}
/**
* @return the lastname
*/
protected String getLastname() {
return lastname;
}
/**
* @param lastname the lastname to set
*/
protected void setLastname(String lastname) {
this.lastname = lastname;
}
/**
* @return the age
*/
protected int getAge() {
return age;
}
/**
* @param age the age to set
*/
protected void setAge(int age) {
if (age >= 18) {
this.age = age;
}
else this.age = 18;
}
/**
* @return the addris
*/
protected String getAddris() {
return addris;
}
/**
* @param addris the addris to set
*/
protected void setAddris(String addris) {
this.addris = addris;
}
}ثاينا
main
كود:
import com.sun.xml.internal.ws.api.pipe.NextAction;
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ELGAZAR
*/
public class main {
public static void main(String[] args) {
employee e = new employee();
Scanner in = new Scanner(System.in);
System.out.println("plees enter your frist name ");
e.setFristname(in.next());
System.out.println("plees enter your frist lastname ");
e.setLastname(in.next());
System.out.println("plees enter your frist addris ");
e.setAddris(in.next());
System.out.println("plees enter your frist age ");
e.setAge(in.nextInt());
System.out.print(e.toString());
System.err.print(e.setAge(age));
}
}المفروض الناتج يظهر الاسم كامل والعنوان والسن ويظهر السن بالوون الاحمر وان كان السن اقل من 18 عام يصبح 18 فين الغلط الفى الكود معل العلم انى اتدرب على
seter , geter
