/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Car {
// الخصائص Attributes
int year;
double price;
// Constructor
public Car
( String brand,
String model,
int year,
double price
) { this .brand = brand;
this .model = model;
this .year = year;
this .price = price;
}
// عرض معلومات السيارة
public void displayInfo( ) {
System .
out .
println ( "اسم الشركة: " + brand
) ; System .
out .
println ( "طراز السيارة: " + model
) ; System .
out .
println ( "سنة الصنع: " + year
) ; System .
out .
println ( "السعر: " + price
) ; }
// دالة تصنيف السيارة حسب السعر
public void checkStatus( ) {
if ( price >= 30000 ) {
System .
out .
println ( "سيارة فخمة" ) ; }
else if ( price >= 15000 && price < 30000 ) {
System .
out .
println ( "سيارة متوسطة" ) ; }
else {
System .
out .
println ( "سيارة اقتصادية" ) ; }
}
}
// الكلاس الرئيسي
public class Main {
public static void main
( String [ ] args
) {
// إنشاء كائنات
Car c1 = new Car( "Toyota" , "Corolla" , 2022 , 25000 ) ;
Car c2 = new Car( "BMW" , "X5" , 2023 , 55000 ) ;
Car c3 = new Car( "Kia" , "Rio" , 2020 , 12000 ) ;
// عرض النتائج
c1.displayInfo ( ) ;
c1.checkStatus ( ) ;
System .
out .
println ( "....................." ) ;
c2.displayInfo ( ) ;
c2.checkStatus ( ) ;
System .
out .
println ( "....................." ) ;
c3.displayInfo ( ) ;
c3.checkStatus ( ) ;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KCgoJY2xhc3MgQ2FyIHsKICAgIC8vINin2YTYrti12KfYpti1IEF0dHJpYnV0ZXMKICAgIFN0c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ub3V0LnByaW50bG4oItiz2YrYp9ix2Kkg2YXYqtmI2LPYt9ipIik7CiAgICAgICAgfSAKICAgICAgICBlbHNlIHsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCLYs9mK2KfYsdipINin2YLYqti12KfYr9mK2KkiKTsKICAgICAgICB9CiAgICB9Cn0KCi8vINin2YTZg9mE2KfYsyDYp9mE2LHYptmK2LPZigpwdWJsaWMgY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CgogICAgICAgIC8vINil2YbYtNin2KEg2YPYp9im2YbYp9iqCiAgICAgICAgQ2FyIGMxID0gbmV3IENhcigiVG95b3RhIiwgIkNvcm9sbGEiLCAyMDIyLCAyNTAwMCk7CiAgICAgICAgQ2FyIGMyID0gbmV3IENhcigiQk1XIiwgIlg1IiwgMjAyMywgNTUwMDApOwogICAgICAgIENhciBjMyA9IG5ldyBDYXIoIktpYSIsICJSaW8iLCAyMDIwLCAxMjAwMCk7CgogICAgICAgIC8vINi52LHYtiDYp9mE2YbYqtin2KbYrAogICAgICAgIGMxLmRpc3BsYXlJbmZvKCk7CiAgICAgICAgYzEuY2hlY2tTdGF0dXMoKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIi4uLi4uLi4uLi4uLi4uLi4uLi4uLiIpOwoKICAgICAgICBjMi5kaXNwbGF5SW5mbygpOwogICAgICAgIGMyLmNoZWNrU3RhdHVzKCk7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCIuLi4uLi4uLi4uLi4uLi4uLi4uLi4iKTsKCiAgICAgICAgYzMuZGlzcGxheUluZm8oKTsKICAgICAgICBjMy5jaGVja1N0YXR1cygpOwogICAgfQp9Cg==