السلام عليكم . . شباب \ شابات في سؤال محيرني اذا تساعدوني فيه .؟
السؤال يقول : (1) أنشئ كلاس إنشاء موظف في البنك.. مواصفاته(رقم الموظف،اسمه،راتبه) .
(2) قم بإنشاء Method لزيادة راتب موظف ما 20% .
(3) في الـ main class قم بإنشاء موظف جديد وقم بزيادة راتبه بإستخدام الـ method التي أنشأتها في الخطوة السابقة .
انا سويت الأول . بس الثاني و الثالث صراحة ما عرفت لها كيف ازيد راتبه 20% ؟؟؟ . هذا class الأول :
package ASNAF;
public class BE {
private long EmployeeId ;
private String EmployeeUser ;
private double EmployeeSalary ;
public BE(long EmployeeId, String EmployeeUser, double EmployeeSalary) {
this.EmployeeId = EmployeeId ;
this.EmployeeUser = EmployeeUser ;
this.EmployeeSalary = EmployeeSalary ;
}
public long getEmployeeId() {
return EmployeeId ;
}
public void setEmployeeId(long EmployeeId) {
this.EmployeeId = EmployeeId ;
}
public String getEmployeeUser() {
return EmployeeUser ;
}
public void setEmployeeUser(String EmployeeUser) {
this.EmployeeUser = EmployeeUser;
}
public double getEmployeeSalary() {
return EmployeeSalary;
}
public void setEmployeeSalary(double EmployeeSalary) {
this.EmployeeSalary = EmployeeSalary;
}
}
اما بالنسبة للــ main classs انا ماكتبته بس عندي كلاس قديم تقريبا قريب من المسئلة هذي :[/color]
package ASNAF;
//import java.util.Scanner;
import ASNAF.BE;
import javax.swing.JOptionPane;
public class BE_main {
// static Scanner input = new Scanner(System.in) ;
static int ch ;
static String sInput ;
static double amount ;
static BE BankEmployee ;
static double oldCredit ;
public static void main(String[] args, BankAccount BE) {
BE = new BankAccount(10, "Nasser", 1000);
JOptionPane.showMessageDialog(null, "معلومات عن العميل \n\t رقم العميل = " + BE.getAccountId() + "\n\t اسم العميل = " + BE.getAccountUser() + "\n\t حساب العميل = " + BE.getAccountCredit() + "$");
inputInfo();
}
public static void inputInfo() {
sInput = JOptionPane.showInputDialog("للأيداع اكتب الرقم (1)\n للسحب اكتب الرقم (2)\n لألغاء العملية اكتب الرقم (3)");
ch = Integer.parseInt(sInput);
bankOpertions();
}
public static void bankOpertions() {
switch (ch) {
case 1:
sInput = JOptionPane.showInputDialog("أدخل المبلغ المطلوب ايداعه");
amount = Double.parseDouble(sInput);
if (amount >= 0) {
oldCredit = BE.getAccountId();
bankAccount.setAccountCredit(bankAccount.getAccountCredit() + amount);
JOptionPane.showMessageDialog(null, " رقم العميل " + oldCredit + " المبلغ المطلوب ايداعه هو "
+ amount + "$ الحساب الجديد للعميل هو " + bankAccount.getAccountCredit() + "$.");
}
else {
JOptionPane.showMessageDialog(null, " القيمة المدخلة خاطئة ");
inputInfo();
}
break;
case 2:
sInput = JOptionPane.showInputDialog(" ادخل المبلغ المطلوب سحبه ");
amount = Double.parseDouble(sInput);
if (amount <= bankAccount.getAccountCredit() && amount >= 0) {
oldCredit = bankAccount.getAccountId();
bankAccount.setAccountCredit(bankAccount.getAccountCredit() - amount);
JOptionPane.showMessageDialog(null, " رقم العميل " + oldCredit + " المبلغ المطلوب سحبه "
+ amount + "$ الحساب الجديد " + bankAccount.getAccountCredit() + "$.");
}
else {
JOptionPane.showMessageDialog(null, " القيمة المدخلة خاطئة ");
inputInfo();
}
break;
case 3:
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null, " الرجــاء الأختـــيار من القائمـــة");
inputInfo();
}
}
}اتمنى انكم تفيدوني . ويعطيكم الف الف عافية .


