ااسلام عليكم ورحمة الله وبركاته
معليه رادة متأخر بس يعني انشغلت بالاختبارات
اما بالنسبة للبروجكت في مطلوبين ماني عارفة اعملهم اللي هم ال3. Rent a carوكمان . Reserve a seat.
كود:
public class ApplicationBus {
boolean isGo = true;
int select;
char select_char;
Scanner scan=new Scanner(System.in);
Bus [] mybus = {new Bus("787FFF","Toyota"," HIACE "),new Bus("909GGB","Ford","Flex",""),new Bus("888YKL","ryanbus","AECMerlin")};
while (isGo) {
System.out.println("\n Welcome to Bus Company Main Menu ");
System.out.println("1)ADD A New Bus \t 2)Remove A Bus \t 3)Reserve a seat \t 4)Exit");
System.out.print(":: ");
select = scan.nextInt();
switch (select) {
case 1:
Boolean isAdd = false;
for (int i = 0; i < mybus.length; i++) {
if (list[i] == null) {
System.out.println("\n--- Enter New Bus ---");
mybus[i] = new Car();
System.out.print("Enter license Plate Number: ");
mybus[i].setLicensePlateNumber(scan.nextLine());
System.out.print("Enter Maker:: ");
mybus[i].setMaker(scan.nextLine());
System.out.print("Enter Model Name: ");
mybus[i].setModelName(scan.nextLine());
isAdd = true;
System.out.println("----------------------");
break;
}
}
if (isAdd == false) {
System.out.println("Can not add the new Bus!");
}
break;
case 2:
String maker;
int index = mybus.length;
for (int i = 0; i < mybus.length; i++){
if ((mybus[i] == null)) break;
if (mybus[i].getMaker().equals(maker)) {
System.out.println("-> " + mycar[i]. + " bus Has been successfully deleted!");
index = i;
mybus[index] = mycar[mybus.length - 1];
mybus[mybus.length - 1] = null;
break;
}
}
if (index == mybus.length){
System.out.println("-> Bus, which has the maker [" + maker + "] does not exist!");
}
break;
case 3:
for(int i = 0; i < mybus.length; i++){
System.out.printf("License Plate Numbes: %s\n", mybus[i].getLicensePlateNumbe());
System.out.printf("Maker: %s\n", mybus[i].getMaker());
System.out.printf("Model Name: %s\n", mybus[i].getmModelName());
System.out.printf("Car Availability: %s\n", mybus[i].getCarAvailability());
}
rent_Select(mybus);
break;
case 4:
System.out.println("..EXIT..");
break;
}
System.out.print("Another operation ? [y-n] : ");
select_char = scan.next().charAt(0);
if (select_char == 'y') {
System.out.println("--------------------------");
continue;
}
else
break;
}
System.out.println("..Thank you..");
}
}
وهذي كلاس وحدة حق مين الكار وطبعا مو كاملة لأني ماني عارفة اكمل على المطلوب اللي هو Rent a car