[لسلام عليكم
اخواني واخواتي انا عضو جديد في المنتدى ... وايضا مبتدئ في لغة الجافا ... اتمنى من الله ان اجد الفائدة عندكم
مطلوب مني برنامج !!!! انا قمت بالمحاولة وهذا هو حلي اتمنى منكم ان تبيوني لي خطئي
وهو ببرنامج JCreator
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
الحل (main)
/**
* @(#)HW5.java
*
* HW5 application
*
* @author
* @version 1.00 2010/5/7
*/
import java.util.*;
import java.text.*;
public class HW5 {
public static void main(String[] args) {
Lab lab1,lab2,lab3;
lab1=new Lab (1,"A113",30);
lab2=new Lab (1,"B50",40);
lab3=new Lab (1,"B491",40);
System.out.println("1.A113");
System.out.println("2.B50");
System.out.println("3.B49");
do{
System.out.println("Enter your choice:");
Scanner sc=new Scanner(System.in);
int v=sc.nextInt();
System.out.println("Enter number of student:");
Scanner sc=new Scanner(System.in);
int d=sc.nextInt();
if(lab1.isEnough(d))
{ System.out.println("Enter time(1,2,3):"); // the time between (8-10)=1 // (10-12)=2 // (12-2)=3
Scanner sca=new Scanner(System.in);
int g=sca.nextInt();}
else
System.out.print("Sorry .The lab is available but it is small");
}while(v==1||v==2|v==3)
}
}class))
import java.util.*;
import java.text.*;
public class Lab{
private int floorNum;
private String name;
private int capacity;
private boolean slot1, slot2, slot3;
public int d;
public Lab(Lab l1){
slot1 = false ;
slot2 = false ;
slot3 = false ;
int a,c;
String b;
a=l1.floorNum;
b=l1.name;
c=l1.capacity;
Lab l2=new Lab(a,b,c);
}
public Lab( int f, String n, int c){
slot1 = false ;
slot2 = false ;
slot3 = false ;
floorNum=f;
name=n;
capacity=c;
}
public int getFloorNum(){
return floorNum;
}
public String getName(){
return name;
}
public boolean isEnough(int d){
if (d>=capacity)
return true;
else
return false;
}
public boolean isAvailable(int g){
if(g==floorNum&&d<=capacity)
return true;
else
return false;
}
}المطلوب
Create class Lab
Constructor :
1 parameter (Lab object), all slots :false
3 parameters (int,String,int) all slots :false
Get methods(for floorNum & name only)
isEnough: check if the capacity is larger or equal to argument number to return true, otherwise return false
isAvailable : check if the lab is available at the receiving slot time
reservation: make value for receiving slot true, so this slot can not be available any more
Create project HW#5
create 3 Lab objects with following information:
(1,”A113”,30)-(1,”B50”,40)-(1,”B49”,40)
Display labs names (getName)as menu ,Then ask user to choose one of them, and read the number of students.
Let hem to choose the slot time(8-10,10-12,12-2) , it equivalent to 1,2,3
Make sure the selected lab can handle the number of student(isEnough), and it available at entered time(isAvailable).
If these conditions satisfied make selected slot true and print “done”
Otherwise print “sorry”
Repeat until user enter n


