الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

[مخالف]اشرحولي هاد الكود00بليز

مغلق
بدأه java.sun في 10 ديسمبر 2008 · 1 رد · 395 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بســم الله الـرحمــن الرحيــم

ياريت تساعدونس وتشرحولي هاد الكود بالتفصييييييل :blink:

وانا شفت الاخ عيسى بموضوع كان شارح هاد الموضوع ياريت تساعدني هون000وشكرا كتيررررر

Example,

import java.util.*;

public class CloneTest {

public static void main(String[] args)

{

Employee original = new Employee("Jhon", 500);

original.setHireDay(2000,1,1);

Employee copy = (Employee) original.clone();

copy.raiseSalary(10);

copy.setHireDay(2002,12,1);

System.out.println("Original"+original);

System.out.println("Copy "+copy);

}

}

class Employee implements Cloneable {

public Employee(String n, double s)

{

name = n;

salary = s;

}

public Object clone()

{

try {

Employee cloned = (Employee)super.clone();

cloned.hireDay = (Date)hireDay.clone();

return cloned;

}catch(CloneNotSupportedException e) {return null;}

}

public void setHireDay (int year, int month, int day)

{

hireDay = new GregorianCalendar(year,month -1,day).getTime();

}

public void raiseSalary(double percent)

{

double raise = salary * percent/100;

salary += raise;

}

public String toString()

{

return "Emploee(name="+name+"Salary="+salary

+ ", Hira date =" +hireDay;

}

private String name;

private double salary;

private Date hireDay;

}

مممممممممممم وكمان طلب بليزززززززز اللي عنده معلومات عن :blush: :blush:

deep,shallow copy :S :blink:

يساعدني

بليز ياجماعه

#2

الأخ الكريم/الأخت الكريمة

السلام عليكم ورحمة الله وبركاته

مرحباً بكم في منتدى الفريق العربي للبرمجة

تأسف إدارة المنتدى لغلق الموضوع وذلك لمخالفته قوانين المشاركات .

قواعد طرح المشاركات

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

Theory is when you know something, but it doesn't work. Practice is when something works, but you don't know why. Programmers combine theory and practice: Nothing works and they don't know why

هذا الموضوع مغلق.

مواضيع مشابهة