Professional Documents
Culture Documents
This assignment is the continuation of assignment 1, where you are supposed you implement all
the 10 classes that you have modeled in previous assignment, using Java language. You are also
supposed to create the objects to each class in main method and call appropriate method.
1. Employee Class
class Employee{
private final String Name;
private String Designation, Email;
private final int Salary;
public void setDesignation(String Designation) { this.Designation = Designation; }
public void setEmail(String Email) { this.Email = Email; }
public Employee(String Name, String Designation, String Email, int Salary) {
this.Name = Name;
this.Designation = Designation;
this.Email = Email;
this.Salary = Salary;
}
public void Display(){
System.out.println("Name : " + Name);
System.out.println("Designation : " + Designation);
System.out.println("Email : " + Email);
System.out.println("Salary : " + Salary);
}
}
public class Main {
public static void main(String[] args) {
Employee e1 = new Employee("Noman", "Receptionist", "nomanjr123@gmail.com",
40000);
e1.Display();
}
}
class Car{
private final String model, name, VIN;
private String color;
int year;
public Car(String name, String model, String VIN, String color, int year) {
this.name = name;
this.model = model;
this.VIN = VIN;
this.color = color;
this.year = year;
}
public void setColor(String color) { this.color = color; }
public String getVIN() { return VIN; }
public void Display() {
System.out.println("\t\tCar Details");
System.out.println("Name : " + name);
System.out.println("Model : " + model);
System.out.println("Year : " + year);
System.out.println("VIN : " + VIN);
System.out.println("Color : " + color);
}
}
public class Main {
public static void main(String[] args) {
Car corolla = new Car("Corolla", "Altis", "APG-123", "Blue", 2021);
corolla.setColor("Blue");
corolla.Display();
}
}
3. Customer Class
Name: Rizwan Akram Enrollment No. : 02-131212-026
class Customer{
String[] Item_Name;
Date date = new Date();
int Customer_Id;
double Payment;
public Customer(String[] name, double payment) {
Item_Name = name;
Customer_Id++;
Payment = payment;
}
public double getPayment() { return Payment; }
public void generateBill(){
System.out.println("\t\t Imtiaz Utility Store");
System.out.printf(" \t %s\n", date.toLocaleString());
System.out.println("Name : " + Arrays.toString(Item_Name));
System.out.println("Customer Id : " + Customer_Id);
System.out.println("Payment : " + Payment);
}
}
public class Main {
public static void main(String[] args) {
Customer C1 = new Customer(new String[]{"Biscuits", "Chocolate"}, 3400);
C1.generateBill();
}
}
4. Book Class
class Book{
int no_OfPages, Price;
String Name;
public void setPrice(int price) { Price = price; }
public Book(String Name, int no_OfPages, int price) {
this.Name = Name;
this.no_OfPages = no_OfPages;
Price = price;
}
public void Display() {
System.out.println("\t\tBook Details");
System.out.println("Name : " + Name);
System.out.println("No. Of Pages : " + no_OfPages);
System.out.println("Price : " + Price);
}
}
public class Main {
public static void main(String[] args) {
Book HarryPotter = new Book("Harry Potter",23, 1000);
HarryPotter.Display();
}
}
class Item{
String Name;
int Quantity;
int UnitPrice;
class Food{
private final String Name, Type;
private final int Price;
Date ExpDate;
public Food(String name, String type, int price) {
Name = name;
Type = type;
Price = price;
}
public void setExpDate(String Date) {
try {
ExpDate = new SimpleDateFormat("dd/MM/yy").parse(Date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
public void Display(){
System.out.println("\t\t Food Info");
System.out.println("Name : " + Name);
System.out.println("Type : " + Type);
System.out.println("Price : " + Price);
System.out.println("ExpDate : " + ExpDate.toLocaleString());
}
}
public class Main {
public static void main(String[] args) {
Food BBQ = new Food("BBQ", "Fast Food", 2000);
BBQ.setExpDate("3/12/2022");
BBQ.Display();
}
}
7. Student Class
8. Bank Class
class Person{
String Name;
int Age, Salary;
public void setSalary(int salary) { Salary = salary; }
class Shape{
String Name;
int Area, Length;
public void setArea(int area) { Area = area; }
public int calculateArea(){
return Area = Length * Length;
}
public Shape(String name, int length) {
Name = name;
Length = length;
}
public void DisplayArea() {
System.out.printf("Area Of The %s Is %d sq.meter\n\n", Name, Area);
}
}
public class Main {
public static void main(String[] args) {
Shape Square = new Shape("Square", 12);
Square.calculateArea();
Square.DisplayArea();
}
}