0% found this document useful (0 votes)
6 views9 pages

Customer and Restaurant Class Design

Uploaded by

Samhitha K
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

Customer and Restaurant Class Design

Uploaded by

Samhitha K
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Encapsulation Questions

1. Design a Customer class in Java with private attributes for customer


information, including`id`, `name`, `email`, `phone`, `password`, and
`address`. Implement encapsulation by providing appropriate getters and
setters for each attribute.
Create one object of Customer & take the inputs from the user, set the values
& display the values using setter and getters.

Sample Input:
1

Y
Alex
alex@[Link]

EM
9988776655
Alex@123
Btm layout, Bengaluru

Sample Output:
AD
1
Alex
alex@[Link]
9988776655
Alex@123
AC

Btm layout, Bengaluru

2. Design a Customer class in Java with private attributes for customer


information, including`id`, `name`, `email`, `phone`, `password`, and
`address`. Implement encapsulation by providing appropriate getters and
P

setters for each attribute.


Create multiple objects of Customer according to the user & take the inputs
TA

from the user, set the values & display the values using setter and getters.

Sample Input:
3
1
Alex
alex@[Link]
9988776655
Alex@123
Btm layout, Bengaluru
2
Bob
bob@[Link]
8899664455
Bob@123
Banashankari, Bengaluru

3
Aravind
aravind@[Link]
9988776655
Aravind@123

Y
Jnanabharathi, Bengaluru

EM
Sample Output:
1
Alex
alex@[Link]
AD
9988776655
Alex@123
Btm layout, Bengaluru

2
AC

Bob
bob@[Link]
8899664455
Bob@123
Banashankari, Bengaluru
P

3
Aravind
TA

aravind@[Link]
9988776655
Aravind@123
Jnanabharathi, Bengaluru

3. Design a Customer class in Java with private attributes for customer


information, including`id`, `name`, `email`, `phone`, `password`, and
`address`.Create an appropriate constructor and implement encapsulation by
providing appropriate getters and setters for each attribute.
Create an object of Customer & take the inputs from the user, set the values
using constructor display the values using getters.
Sample Input:
1,Alex , alex@[Link] , 9988776655 , Alex@123 , Btm layout Bengaluru

Sample Output:
1
Alex
alex@[Link]
9988776655
Alex@123
Btm layout, Bengaluru

4. Design a Customer class in Java with private attributes for customer

Y
information, including`id`, `name`, `email`, `phone`, `password`, and
`address`.Create a appropriate constructor and implement encapsulation by

EM
providing appropriate getters and setters for each attribute.
Create an object of Customer class and take the inputs from the user, verify
the email whether it contains domain name either `[Link]` or
`[Link]` then set the values and display the values using the setter and
getters.
AD
Sample Input:
1
Alex
alex@[Link]
AC

9988776655
Alex@123
Btm layout, Bengaluru

Sample Output:
1
P

Alex
alex@[Link]
TA

9988776655
Alex@123
Btm layout, Bengaluru

5. Design a Customer class in Java with private attributes for customer


information, including`id`, `name`, `email`, `phone`, `password`, and
`address`.Create a appropriate constructor and implement encapsulation by
providing appropriate getters and setters for each attribute.
Create an object of Customer class and take the inputs from the user, verify
the mobile number starts with any of the following numbers 6, 7, 8 or 9, then
set the values and display the values using the setter and getters.
Sample Input:
1
Alex
alex@[Link]
9988776655
Alex@123
Btm layout, Bengaluru

Sample Output:
1
Alex

Y
alex@[Link]
9988776655

EM
Alex@123
Btm layout, Bengaluru

6. Design a Restaurant class in Java with private attributes for restaurant


AD
information, including`id`, `name`, `email`, `phone` and `address`.
Implement encapsulation by providing appropriate getters and setters for
each attribute.
Create an object of Restaurant class and take the user inputs and set the
values and display the values using setters and getters.
AC

Sample Input:
1
Donne Biryani
donnebiryani@[Link]
6677889955
P

Btm layout, Bengaluru


TA

Sample Output:
1
Donne Biryani
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru

7. Design a Restaurant class in Java with private attributes for restaurant


information, including`id`, `name`, `email`, `phone`, and `address`.
Implement encapsulation by providing appropriate getters and setters for
each attribute.
Create multiple objects of the Restaurant according to the user & take the
inputs from the user, set the values & display the values using setter
and getters.

Sample Input:
3
1
Donne Biryani
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru

Y
Rotti Mane
rottimane@[Link]

EM
7895456123
Choodasandra, Bengaluru

3
Swadishta
AD
swadishta@[Link]
2354869575
Marathahalli, Bengaluru

Sample Output:
AC

1
Donne Biryani
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru
P

2
Rotti Mane
TA

rottimane@[Link]
7895456123
Choodasandra, Bengaluru

3
Swadishta
swadishta@[Link]
2354869575
Marathahalli, Bengaluru
8. Design a Restaurant class in Java with private attributes for
restaurant information, including`id`, `name`, `email`, `phone`, and
`address`.Create an appropriate constructor and implement encapsulation by
providing appropriate setters and getters for each attribute.
Create an object of Restaurant & take the inputs from the user, set the values
using constructor display the values using getters.

Sample Input:
1,Donne Biryani , donnebiryani@[Link] , 6677889955 , Btm layout
Bengaluru

Sample Output:

Y
1
Donne Biryani

EM
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru

9. Design a Restaurant class in Java with private attributes for Restaurant


AD
information, including`id`, `name`, `email`, `phone`, and `address`.Create
a appropriate constructor and implement encapsulation by providing
appropriate getters and setters for each attribute.
Create an object of Restaurant class and take the inputs from the user, verify
the email whether it contains the domain name as the name of the restaurant
AC

then set the values and display the values using the setter and getters.

Sample Input:
1
Donne Biryani
biryani@[Link]
P

6677889955
Btm layout, Bengaluru
TA

Sample Output:
1
Donne Biryani
biryani@[Link]
6677889955
Btm layout, Bengaluru

10. Design a Restaurant class in Java with private attributes for restaurant
information, including`id`, `name`, `email`, `phone`, and `address`.Create
a appropriate constructor and implement encapsulation by providing
appropriate getters and setters for each attribute.
Create an object of Restaurant class and take the inputs from the
user, verify the mobile number starts with any of the following numbers 6, 7, 8
or 9, then set the values and display the values using the setter and getters.

Sample Input:
1
Donne Biryani
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru

Sample Output:

Y
1
Donne Biryani

EM
donnebiryani@[Link]
6677889955
Btm layout, Bengaluru
AD
11. Design a Menu class in Java with private attributes for menu information,
including `id`, `name`, `price`, and `description` . Implement
encapsulation by providing appropriate getters and setters for each attribute.
Create one object of Menu & take the inputs from the user, set the values &
display the values using setter and getters.
AC

Sample Input:
1
Paneer Butter Masala
250
A butter rich paneer curry
P

Sample Output:
TA

1
Paneer Butter Masala
250
A butter rich paneer curry

12. Design a Menu class in Java with private attributes for menu information,
including `id`, `name`, `price`, and `description`. Implement encapsulation
by providing appropriate getters and setters for each attribute.
Create multiple objects of Menu according to the user & take the inputs from
the user, set the values & display the values using setter and getters.

Sample Input:
3
1
Paneer Butter Masala
250
A butter rich paneer curry

2
Green Peas Pulav
180
Enriched with green peas cooked with basmati rice

Y
South Indian Thali
160

EM
Two Chapati, Two Bhaji, One Sweet, Butter Milk, Steam Rice

Sample Output:
1
AD
Paneer Butter Masala
250
A butter rich paneer curry

2
AC

Green Peas Pulav


180
Enriched with green peas cooked with basmati rice

3
South Indian Thali
P

160
Two Chapati, Two Bhaji, One Sweet, Buttermilk, Steam Rice
TA

13. Design a Menu class in Java with private attributes for menu information,
including`id`, `name`, `price`, and `description`.Create an appropriate
constructor and implement encapsulation by providing appropriate getters
and setters for each attribute.
Create an object of Menu & take the inputs from the user, set the values using
constructor display the values using getters.

Sample Input:
1,Paneer Butter Masala, 250, A butter rich paneer curry
Sample Output:
1
Paneer Butter Masala
250
A butter rich paneer curry

Y
EM
AD
AC
P
TA

You might also like