Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A friend of yours owns two houses at Football City, the site of the next Super B

ID: 3529977 • Letter: A

Question

A friend of yours owns two houses at Football City, the site of the next Super Bowl. Your friend wants to rent those two houses for the Friday, Saturday, and Sunday of the Super Bowl weekend. House #1 has 3BR (3 Bedrooms), 3BA (3 Baths), and house #2 has 1 BR, 1BA. For this project, concurrency is not an issue; you should assume that two customers will never access your system at exactly the same time. You should also assume that the management-side software and the customer-side software will never run at the same time. We can assume that we run the management-side software first, then the customer-side software. This friend has asked you to build a file-based reservation system enabling the following: A. Management-side software: Your friend controls the rental price and may change it every day. He/she sends you a change file every day; this file may be empty, in which case there are no pricing changes. If the file is not empty, pricing has changed (for one or more houses, or for one or more days). You are in charge of this project, and therefore, you are in charge of specifying the file format; however, this must be simple text file because your friend is not a computer person. You do not have to simulate the act of sending the file by your friend; you should assume that the file is a text file in your directory and that you only need to read the data. Your management-side software needs to read this file and update a different file, with which you control the reservation system. You can create your own design for the structure of that file. Of course, prices for existing reservations cannot be changed. Finally, your management-side software should write to a file the status of the reservations; that is, which house is rented to whom, when, and for what price.

Explanation / Answer

Hey i have wriiten the code you want.please check it out..You have provide 3 file name


1 : c://priceList.txt

2 : c://ReservationPriceDetail.txt

3 : c://status.txt


The code for Reservation system Management-side-Class

import java.io.File;
import java.util.Scanner;
import java.util.ArrayList;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.FileNotFoundException;
public class ManagementSideApp {
public static ArrayList<Reservation> reservationList=new ArrayList<Reservation>();
/**
* @param args
*/
public ManagementSideApp()
{
Reservation h1=new Reservation(false,"1","",0);
Reservation h2=new Reservation(false,"2","",0);
reservationList.add(h1);
reservationList.add(h2);
}

public static void main(String[] args) {
// TODO Auto-generated method stub
File f=new File("c://priceList.txt");
File f1=new File("c://ReservationPriceDetail.txt");
try
{
FileWriter fw=new FileWriter(f1);
BufferedWriter bw=new BufferedWriter(fw);
Scanner sc=new Scanner(System.in);
double[] pricelist=new double[2];
if(sc.hasNext())
{
String s=sc.nextLine();
String[] updateArray=s.split(",");
bw.append(" "+s+" ");
for(Reservation r:reservationList)
{
if(updateArray[1].equals(r.getHouseNo()))
{
r.setPrice(Double.parseDouble(updateArray[0]));
}
}
}
Scanner sc1=new Scanner(System.in);
File f2=new File("c://status.txt");
FileWriter fw1=new FileWriter(f1);
BufferedWriter bw1=new BufferedWriter(fw1);
for(Reservation r:reservationList)
{
if(r.getHouseNo().equals("1") && r.isReserved() == false )
{
System.out.println("Reservation for house1");
System.out.println("Enter the name of tenant :");
String tenant=sc1.next();
System.out.println("Enter the no of days to stay");
int n=sc1.nextInt();

r.setHouseNo("1");
r.setReserved(true);
r.setToWhom(tenant);
r.setPrice(r.getPrice());
bw1.append("House No"+r.getHouseNo()+" Price :"+r.getPrice()+" Rented To :"+r.getToWhom()+" Current Status : Reserved");

}
else if(r.getHouseNo().equals("2") && r.isReserved() == false)
{
System.out.println("Reservation for house1");
System.out.println("Enter the name of tenant :");
String tenant=sc1.next();
System.out.println("Enter the no of days to stay");
int n=sc1.nextInt();

r.setHouseNo("1");
r.setReserved(true);
r.setToWhom(tenant);
r.setPrice(r.getPrice());
bw1.append("House No"+r.getHouseNo()+" Price :"+r.getPrice()+" Rented To :"+r.getToWhom()+" Current Status : Reserved");

}
System.out.println("House No"+r.getHouseNo()+" Price :"+r.getPrice()+" Rented To :"+r.getToWhom()+" Current Status : Reserved");
}

}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}

}

}

The code for Reservation Class


public class Reservation {

private boolean reserved;
private String houseNo;
private String toWhom;
private double price;
public Reservation() {
super();
}
public Reservation(boolean reserved, String houseNo, String toWhom,
double price) {
super();
this.reserved = reserved;
this.houseNo = houseNo;
this.toWhom = toWhom;
this.price = price;
}
public boolean isReserved() {
return reserved;
}
public void setReserved(boolean reserved) {
this.reserved = reserved;
}
public String getHouseNo() {
return houseNo;
}
public void setHouseNo(String houseNo) {
this.houseNo = houseNo;
}
public String getToWhom() {
return toWhom;
}
public void setToWhom(String toWhom) {
this.toWhom = toWhom;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}


}

Code for the owner class to prepare the new price list file (Manager.java)


import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
public class Manager {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int choice=0;
double price1=0,price2=0;
int num1=0,num2=0;
System.out.println("Want to change the price of 1st house : press 1 for yes and 2 for no");
choice=sc.nextInt();
if(choice == 1)
{
System.out.println("Enter the Price for House 1 (3 BR)");
price1 = sc.nextDouble();
System.out.println("Enter for no of days you want to change the price");
num1=sc.nextInt();
}
System.out.println("Want to change the price of 2nd house : press 1 for yes and 2 for no");
choice=sc.nextInt();
if(choice == 1)
{
System.out.println("Enter the Price for House 1 (3 BR)");
price2 = sc.nextDouble();
System.out.println("Enter for no of days you want to change the price");
num1=sc.nextInt();
}
try
{
File f=new File("c:/priceList.txt");
FileWriter fw=new FileWriter(f);
BufferedWriter bw=new BufferedWriter(fw);
bw.write(price1+", 1 ,"+num1+" "+price2+", 2 ,"+num2+" ");
}
catch(FileNotFoundException e)
{
System.out.println("File specified is not found");
}
catch(IOException e)
{
System.out.println("An error in writing file");
}

}

}


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote