Anda di halaman 1dari 5

National Institute of Technology

Tiruchirappalli

Object Oriented Analysis and Design


ASSIGNMENT
(2017-2018)

Submitted To: Submitted By:


Dr. S. R. Balasundaram Shivani Sahu
Roll No.: 205116029
import java.io.*;
import java.lang.*;
import java.util.*; class
Contact
{
String name;
public Contact( Scanner sc)
{
System.out.println("\nEnter Name:");
name=sc.nextLine();
}
void print()
{
System.out.println("\n The Name:" +name);
}
}
class SocialContact
{
String fid;
String bday;
public SocialContact( Scanner sc)
{
System.out.println("\nEnter The Facebook id ");
fid=sc.nextLine();
System.out.println("\nEnter The Birthday Date:");
bday=sc.nextLine();
}
void print()
{
System.out.println("\nThe Facebook Id:" +fid+"The Birthday Date is:"+bday);
}
}
abstract class Appointment
{ String date,location,time,description;
void read( Scanner sc)
{
System.out.println("\n Enter the Date of Appointment,location, time and description:");
date=sc.nextLine(); location=sc.nextLine();
time=sc.nextLine(); description=sc.nextLine();
}
void display()
{
System.out.println("\n The Date of Appoinment Date:"+date);
System.out.println("\n The Date of Appoinment Location:"+location);
System.out.println("\n The Date of Appoinment Time:"+time);
System.out.println("\n The Date of Appoinment Description:"+description); } }
interface Notes
{
void readNodes();
void displayNotes();
}
class AddressBook extends Appointment implements Notes
{
Contact contact;
SocialContact scontact;
Scanner sc;
String description;

public AddressBook(Scanner c)
{
sc=c;
contact=new Contact(sc);
scontact=new SocialContact(sc);
super.read(sc); readNodes();
}
public void display()
{
contact.print();
scontact.print();
super.display();
displayNotes();
}
public void readNodes()
{
System.out.println("\n Enter the description of Appoinment:");
description=sc.nextLine();
}
public void displayNotes()
{

System.out.println("\n The description is:"+description);


}
boolean getDate(String dt)
{
if((super.date).equals(dt))
return true;
else if(scontact.bday.equals(dt))
return true;
else
return false;
}
}
class Organiser
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
LinkedList<AddressBook> adbook=new LinkedList<AddressBook>();
String ch="y";
while(ch.equals("y"))
{

adbook.add(new AddressBook(sc));
System.out.println("\n Enter y for more detailed information:");
ch=sc.nextLine();
}
System.out.println("\n Enter the date:");
ch=sc.nextLine();
for(int i=0;i<adbook.size();i++)
{
if(adbook.get(i).getDate(ch));
adbook.get(i).display();
}
}
}

Anda mungkin juga menyukai