Implement a Hash table-based Map using Java
منتدى مصر التقني :: قسم لغات البرمجة Programming languages :: لغة الجافا Java :: نقاش و أستفسارات الاعضاء
صفحة 1 من اصل 1 • شاطر
Implement a Hash table-based Map using Java
لو سمحتوا لو حدا يقدر يعمل الكود ده
Implement a Hash table-based Map using Java Programming Language, the Map class must consist of the following methods. key(), value(), setKey(), setValue(), insert(), find(), erase()
Implement a Hash table-based Map using Java Programming Language, the Map class must consist of the following methods. key(), value(), setKey(), setValue(), insert(), find(), erase()
Hashem- .
- تاريخ التسجيل : 07/04/2020
المساهمات : 3
النقاط : 3
التقيم : 0
الدولة :
الجنس :
رد: Implement a Hash table-based Map using Java
Hashem كتب:لو سمحتوا لو حدا يقدر يعمل الكود ده
Implement a Hash table-based Map using Java Programming Language, the Map class must consist of the following methods. key(), value(), setKey(), setValue(), insert(), find(), erase()
- الكود:
import java.util.*;
public class Hash_Table_Demo {
public static void main(String[] args)
{
// إنشاء Hashtable فارغ
Hashtable<Integer, String> hash_table =
new Hashtable<Integer, String>();
// تعيين قيم السلسلة للمفاتيح فى الجدول
hash_table.put(10, "Geeks");
hash_table.put(15, "4");
hash_table.put(20, "Geeks");
hash_table.put(25, "Welcomes");
hash_table.put(30, "You");
// عرض HashMap
System.out.println("Initial Table is: " + hash_table);
}
}
ـــــــــــــــــــ التوقيع ــــــــــــــــــــ
NEXT- الادارة
- تاريخ التسجيل : 18/02/2011
المساهمات : 446
النقاط : 200660
التقيم : 28
الدولة :
الجنس :
رد: Implement a Hash table-based Map using Java
هاض الحل كامل ولا ناقص اشي لو سمحت
Hashem- .
- تاريخ التسجيل : 07/04/2020
المساهمات : 3
النقاط : 3
التقيم : 0
الدولة :
الجنس :
رد: Implement a Hash table-based Map using Java
Hashem كتب:لو سمحتوا لو حدا يقدر يعمل الكود ده
Implement a Hash table-based Map using Java Programming Language, the Map class must consist of the following methods. key(), value(), setKey(), setValue(), insert(), find(), erase()
هذا السؤال محلول هنا كاملا :
http://www.mathcs.emory.edu/~cheung/Courses/323/Syllabus/Map/hash-impl.html
زهراء- ........
- تاريخ التسجيل : 18/02/2011
المساهمات : 438
النقاط : 769
التقيم : 67
الدولة :
الجنس :
رد: Implement a Hash table-based Map using Java
عفوا في الرابط في كثير كود ومش عارف اي واحد الحل تبع السؤال لو سمحتي
Hashem- .
- تاريخ التسجيل : 07/04/2020
المساهمات : 3
النقاط : 3
التقيم : 0
الدولة :
الجنس :
رد: Implement a Hash table-based Map using Java
Hashem كتب:لو سمحتوا لو حدا يقدر يعمل الكود ده
Implement a Hash table-based Map using Java Programming Language, the Map class must consist of the following methods. key(), value(), setKey(), setValue(), insert(), find(), erase()
أهلا وسهلا بيك الاخ الكريم
يتطلب هذا المثال تطبيق خريطة HashMap وهى أحد مجموعات البيانات التى تعتمد على جدول التجزئة table-based لتخزين البيانات بقيم مزدوجة Key / Value حيث يتم إعطاء مفتاح لكل قيمة يتم تخزينها بداخل الـ HashMap.
بمعنى أوضح أن كل قيمة يتم تخزينها في كائن الـ HashMap يجب إعطاءها مفتاح Key فريد بحيث يسمح لنا بالوصول لقيمة واحدة من القيم الموجودة في كائن الـ HashMap.
إذاً الـ HashMap كأنه جدول يتألف من عامودين, الأول يحتوي المفاتيح ( Keys ) و الثاني يحتوي على القيم ( Values )....واليك مثال بسيط لذلك :
- الكود:
import java.util.HashMap;
public class HashMapMain1 {
public static void main(String[] args) {
// إنشاء خريطة بيانات فارغة
HashMap<Integer, String> Egy = new HashMap<Integer, String>();
// تخزين القيم فى الخريطة
Egy.put(1,"ahmed");
Egy.put(2,"Abdel-Fattah");
Egy.put(3,"Mahmoud");
Egy.put(4,"Ibrahim");
System.out.println(Egy);
}
}
المخرجات :
{1=ahmed, 2=Abdel-Fattah, 3=Mahmoud, 4=Ibrahim}
لكن سؤالك لم يكفي بذلك بل تتطلب انشاء عدد من الطرق التى سيتم استخدمها للتعامل مع الخريطة من حيث الادخال و البحث و الحذف وتتطلب الطرق التالية :
، setKey ()
، setValue ()
، insert ()
، find ()
، erase ()
واليك المثال بالكامل مع انشاء تلك الطرق والشرح موجود بالكود :
- الكود:
import java.util.HashMap;
public class HashMapMain{
int K ;
String V;
// إنشاء HashMap فارغة
static HashMap<Integer, String> Egy = new HashMap<Integer, String>();
public static void main(String[] args) {
// تعيين قيم السلسلة للمفاتيح فى HashMap
Inser(1,"ahmed");
Inser(2,"Abdel-Fattah");
Inser(3,"Mahmoud");
Inser(4,"Ibrahim");
// طباعة محتويات الخريطة
System.out.println("The values in HashMap are:"+Egy);
// أرجاع القيمة المقابلة للمفتاح المحدد
System.out.println("The value is :: "+ Value(3) );
// أرجاع المفتاح المقابل للقيمة المحددة
System.out.println("The Key is :: "+ Key("Ibrahim") );
//التحقق من وجود القيمة المحددة
System.out.println("Is the value present? " + find("Syed"));
//التحقق من وجود المفتاح المحددة
System.out.println("Is the key present? " + find(4));
//حذف المفتاح المحدد
erase(4);
System.out.println("The key (4) was deleted successfully" );
// طباعة محتويات الخريطة
System.out.println("The new values in HashMap are:"+Egy);
//محو القيم بالكامل
erase();
// طباعة محتويات الخريطة
System.out.println("The new values in HashMap are:"+Egy);
}
// طريقة لارجاع الفتاح بمعلومية القيمة
public static int Key( String value) {
for (HashMap.Entry<Integer, String> entry : Egy.entrySet()) {
if (value.equals(entry.getValue())) {
return entry.getKey();
}
}
return 0;
}
// طريقة الرجاع القيمة بمعلومة المفتاح
public static String Value(int key) {
for (HashMap.Entry<Integer, String> entry : Egy.entrySet()) {
if (key==entry.getKey()) {
return entry.getValue();
}
}
return null;
}
// طريقة لتعين مفتاح
public void setKey(int key) {
this.K= key;
}
//طريقة لتعين قيمة للمفتاح
public void setValue(String value) {
this.V= value;
}
// طريقة للاضافة الى الخريطة وتعيين قيم
public static void Inser(int key, String value) {
Egy.put(key, value);
}
// طريقة للبحث عن قيمة فى الخرطية
public static boolean find(String value) {
boolean containsValue = Egy.containsValue(value);
return containsValue;
}
//طريقة للبحث عن مفتاح فى الخريطة
public static boolean find(int key) {
boolean containsValue = Egy.containsValue(key);
return containsValue;
}
// طريقةلمحو او حذف مفتاح من الخريطة
public static void erase(int key) {
Egy.remove(key);
}
// طريقةلمحو او حذف الخريطة
public static void erase() {
Egy.clear();
}
}
المخرجات :
ـــــــــــــــــــ التوقيع ــــــــــــــــــــ
سبحان الله وبحمدة .....سبحان الله العظيم
احتاج الى مساعده بالجافا
اولا السلام عليكم
احتاج لمساعدة لدي اختبار بعد ساعتين من الان اختبار بالجافا درست سنة أولى I.T وثم اكملت الدراسه C.S
ولكن لم اتمكن من اللحاق ببعض المحاضرات بالجافا بسبب التشديد بالمطارات اتاخرت بالسفر والان احتاج لبعض المساعده فضلا منكم لمن يقدر ان يساعدني لا يبخل
وتحياتي لكم من اليمن
ملاحظه طريقة الاختبار ستكون كالاتي هذه هو سنبل الاختبار
صفحه ١
Sample ExamII CSCI300 - Fall 2020
Part I: Implement the following classes
Consider the following UML diagram for an application that manages spheres in the 3D space.
Question 1:
Create the class Point
Implement the no-arg and all-arg constructors.
Implement the calculateDistance method that returns the distance between
two points.
Implement the isEqual method that returns true if all coordinates are equal in both
points and false otherwise.
Implement the toString() method. If x=2.0, y=3.5, and z=4.0, then the method
returns a string in the form: (2.0, 3.5, 4.0)
Question 2:
Create the class Sphere
Implement the two constructors.
The no-arg constructor should initialize the color to “black”, the radius to 1.0,
and the center to (0.0, 0.0, 0.0).
Implement the getCenter method that returns the center of the sphere. Don’t
implement the rest of getters and setters.
Implement the method calculateVolume() that returns the volume of the
sphere.
Sphere
-radius: double
-center: Point
-color: String
+Sphere( )
+Sphere (radius: double, center: Point,
color: String)
+getCenter( ):Point
+calculateVolume(): double
+isEqual(sphere:Shpere):boolean
+toString(): String
Point
-x: double
-y: double
-z: double
+Point( )
+Point(x: double, y: double, z: double)
+calculateDistance(point :Point) :double
+isEqual(point : Point) :boolean
+toString(): String
صفحه ٢
푉표푚푢푛푓 =
4
3
× 휋 × 푠푎푒푖푢푡3
Implement the isEqual method that returns true if both spheres have the same
center and radius and false otherwise.
Override the toString() method. The method returns a string in the form:
Sphere{Radius:2.0, Center:(1.0, 2.0, 3.0), Color:RD, Volume:33.49333}. Note that
you should only display the first and last letters of the color capitalized.
Part II: Write an application (driver program) for the classes in Part I
Complete the application (driver class) TestSphere as requested below.
Write code to perform the following operations:
a) Create an array of 3 spheres.
b) Ask the user to enter the radius, color, and center coordinates for these spheres:
Create them.
Store them inside the array.
c) Print the information of all spheres (using the toString() method)
d) Print the number of spheres with volume greater than 50.
e) Print whether or not the first and last spheres are equal.
f) Print the distance between the centers of the second and last spheres.
احتاج لمساعدة لدي اختبار بعد ساعتين من الان اختبار بالجافا درست سنة أولى I.T وثم اكملت الدراسه C.S
ولكن لم اتمكن من اللحاق ببعض المحاضرات بالجافا بسبب التشديد بالمطارات اتاخرت بالسفر والان احتاج لبعض المساعده فضلا منكم لمن يقدر ان يساعدني لا يبخل
وتحياتي لكم من اليمن
ملاحظه طريقة الاختبار ستكون كالاتي هذه هو سنبل الاختبار
صفحه ١
Sample ExamII CSCI300 - Fall 2020
Part I: Implement the following classes
Consider the following UML diagram for an application that manages spheres in the 3D space.
Question 1:
Create the class Point
Implement the no-arg and all-arg constructors.
Implement the calculateDistance method that returns the distance between
two points.
Implement the isEqual method that returns true if all coordinates are equal in both
points and false otherwise.
Implement the toString() method. If x=2.0, y=3.5, and z=4.0, then the method
returns a string in the form: (2.0, 3.5, 4.0)
Question 2:
Create the class Sphere
Implement the two constructors.
The no-arg constructor should initialize the color to “black”, the radius to 1.0,
and the center to (0.0, 0.0, 0.0).
Implement the getCenter method that returns the center of the sphere. Don’t
implement the rest of getters and setters.
Implement the method calculateVolume() that returns the volume of the
sphere.
Sphere
-radius: double
-center: Point
-color: String
+Sphere( )
+Sphere (radius: double, center: Point,
color: String)
+getCenter( ):Point
+calculateVolume(): double
+isEqual(sphere:Shpere):boolean
+toString(): String
Point
-x: double
-y: double
-z: double
+Point( )
+Point(x: double, y: double, z: double)
+calculateDistance(point :Point) :double
+isEqual(point : Point) :boolean
+toString(): String
صفحه ٢
푉표푚푢푛푓 =
4
3
× 휋 × 푠푎푒푖푢푡3
Implement the isEqual method that returns true if both spheres have the same
center and radius and false otherwise.
Override the toString() method. The method returns a string in the form:
Sphere{Radius:2.0, Center:(1.0, 2.0, 3.0), Color:RD, Volume:33.49333}. Note that
you should only display the first and last letters of the color capitalized.
Part II: Write an application (driver program) for the classes in Part I
Complete the application (driver class) TestSphere as requested below.
Write code to perform the following operations:
a) Create an array of 3 spheres.
b) Ask the user to enter the radius, color, and center coordinates for these spheres:
Create them.
Store them inside the array.
c) Print the information of all spheres (using the toString() method)
d) Print the number of spheres with volume greater than 50.
e) Print whether or not the first and last spheres are equal.
f) Print the distance between the centers of the second and last spheres.
العريقي١- ..
- تاريخ التسجيل : 21/05/2021
المساهمات : 12
النقاط : 22
التقيم : 0
الدولة :
الجنس :
| |
منتدى مصر التقني :: قسم لغات البرمجة Programming languages :: لغة الجافا Java :: نقاش و أستفسارات الاعضاء
صفحة 1 من اصل 1
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى
الأحد مارس 17, 2024 1:52 pm من طرف رانيا حماد
» افضل شركة نقل عفش بالرياض نقل باكستاني 40% خصم | موقع الانوار
الأحد مارس 17, 2024 1:25 pm من طرف رانيا حماد
» افضل معلم جبس بالرياض تركيب جبس بورد بالرياض 20% خصم اتصل الآن
الأحد مارس 17, 2024 1:09 pm من طرف رانيا حماد
» شراء اثاث مستعمل بالكويت بخصم 30%
الأحد مارس 17, 2024 12:54 pm من طرف رانيا حماد
» افضل فني كهربائي منازل بالرياض جودة 100% | اتصل الآن
الأحد مارس 17, 2024 12:36 pm من طرف رانيا حماد
» أفضل فني سباك بالرياض ممتاز بالرياض | اتصل الآن
الأحد مارس 17, 2024 12:25 pm من طرف رانيا حماد
» افضل شركة تنظيف اثاث بالرياض تنظيف كنب واجهات حجر بخصم 40%
الأحد مارس 17, 2024 11:52 am من طرف رانيا حماد
» افضل شركة تنظيف فلل بالرياض | الانوار
الأحد مارس 17, 2024 11:22 am من طرف رانيا حماد
» افضل شركة تنظيف واجهات زجاج بالرياض 30% خصم
الأحد مارس 17, 2024 10:38 am من طرف رانيا حماد
» افضل شركة نقل عفش بالكويت بخصم 20%
الخميس مارس 14, 2024 1:36 pm من طرف رانيا حماد