0% found this document useful (0 votes)
55 views5 pages

Fzer 63

The document defines classes and interfaces for a book rental system including a BookRental class to store rental details, a Customer class to represent customers, and a BookRentalService interface with implementations to manage book rentals. The BookRentalServiceImpl class implements methods to create, delete, and retrieve book rentals using a BookRental array to store rental objects.

Uploaded by

Vaibhav Desale
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)
55 views5 pages

Fzer 63

The document defines classes and interfaces for a book rental system including a BookRental class to store rental details, a Customer class to represent customers, and a BookRentalService interface with implementations to manage book rentals. The BookRentalServiceImpl class implements methods to create, delete, and retrieve book rentals using a BookRental array to store rental objects.

Uploaded by

Vaibhav Desale
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
You are on page 1/ 5

package com.unext.

adapt;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.naming.InvalidNameException;

class BookRental
{
int rentalid;
int userid;
int bookid;
int quantity;
String startdate;
String enddate;
int totalamount;
String returndate;
Customer customer;
public BookRental(int rentalid, int userid, int bookid, int quantity,
String startdate, String enddate, int totalamount, String returndate,Customer customer) {
super();
this.rentalid = rentalid;
this.userid = userid;
this.bookid = bookid;
this.quantity = quantity;
this.startdate = startdate;
this.enddate = enddate;
this.totalamount = totalamount;
this.returndate = returndate;
this.customer=customer;
}

@Override
public String toString() {
return "BookRental [rentalid=" + rentalid + ", userid=" + userid
+ ", bookid=" + bookid + ", quantity=" + quantity
+ ", startdate=" + startdate + ", enddate=" + enddate
+ ", totalamount=" + totalamount + ", returndate=" + returndate
+ ", customer=" + customer + "]";
}
public int getRentalid() {
return rentalid;
}
public void setRentalid(int rentalid) {
this.rentalid = rentalid;
}
public int getUserid() {
return userid;
}
public void setUserid(int userid) {
this.userid = userid;
}
public int getBookid() {
return bookid;
}
public void setBookid(int bookid) {
this.bookid = bookid;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getStartdate() {
return startdate;
}
public void setStartdate(String startdate) {
this.startdate = startdate;
}
public String getEnddate() {
return enddate;
}
public void setEnddate(String enddate) {
this.enddate = enddate;
}
public int getTotalamount() {
return totalamount;
}
public void setTotalamount(int totalamount) {
this.totalamount = totalamount;
}
public String getReturndate() {
return returndate;
}
public void setReturndate(String returndate) {
this.returndate = returndate;
}

}
class Customer {

private int userId;


private String emailId;
private String password;
private String firstName;
private String lastName;
private String city;
private String gender;
private long phoneNumber;

// private Address address;


public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String name) {
this.lastName = name;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public long getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(long phoneNumber)
{
this.phoneNumber = phoneNumber;
}
public Customer(int userId, String emailId, String password, String firstName, String lastName, String city,
String gender, long phoneNumber)
{
super();
this.userId = userId;
this.emailId = emailId;
this.password = password;
this.firstName = firstName;
this.lastName = lastName;
this.city = city;
this.gender = gender;
this.phoneNumber = phoneNumber;
}
public Customer(){}
@Override
public String toString() {
return "Customer [userId=" + userId + ", emailId=" + emailId + ", password=" + password + ", firstName="
+ firstName + ", lastName=" + lastName + ", city=" + city + ", gender=" + gender + ", phoneNumber="
+ phoneNumber + "]";
}
}

interface BookRentalService {
void createBookRental(BookRental brental);
//BookRental updateBookRental(BookRental brental);
void deleteBookRental(int id);
// BookRental searchBookRental(int id);
BookRental[] getBookRental();
}

class BookRentalServiceImpl implements BookRentalService


{
public static BookRental customerArray[]=new BookRental[2];
static int count=0;

@Override
public void createBookRental(BookRental customer) {
// TODO Auto-generated method stub
customerArray[count]=customer;
count++;
}

/* @Override
public BookRental updateBookRental(BookRental customer) {
// TODO Auto-generated method stub

for(int i=0;i<customerArray.length;i++)
{
if(customerArray[i].getRentalid()==customer.getRentalid())
{
customerArray[i]=customer;
return customer;
}
}
return customer;
}*/

@Override
public void deleteBookRental(int id) {
// TODO Auto-generated method stub
boolean flag=false;
for(int i=0;i<customerArray.length;i++)
{
if(customerArray[i].getRentalid()==id)
{
customerArray[i]=null;
flag=true;
}
}

/* @Override
public BookRental searchBookRental(int id) {
// TODO Auto-generated method stub

for(int i=0;i<customerArray.length;i++)
{
if(customerArray[i].getRentalid()==id)
{
return customerArray[i];
}
}

// throw new CustomerNotFoundException();


return customerArray;

}
*/

@Override
public BookRental[] getBookRental() {
// TODO Auto-generated method stub
return customerArray;
}

public class Source8 {


public static void main(String args[]) {}
}

You might also like