Hi,
I ap posting my Assignment subject here, and hope to get some helps with each Classes, I am not asking that you do all my home works but to give me hints as I want to learn something and as I am new to Java I am block some times.
this is the Subject
The program allows customers to list the videos available and to borrow them (ignore returning videos). It records whether a video is on the shelf or on loan, and if it is on loan, the date it is due to be returned.
Customers can borrow up to two videos for 3 days. Build the program according to the following recipe:
There should be classes describing customers and videos and also a class called VideoStore that
contains ArrayLists of customers and videos. There should also be a small public class VideoTest
that contains the main() method.The Video class has instance fields for the video title, whether it is on loan and the date it is due to be
returned. There are get and set methods for some of these fields and a toString() method.The Customer class has instance fields for the customer name and for the number of videos he is
borrowing. A method borrowvideo(Video v) checks that the video is available and that the
customer is not borrowing more than 2 videos, it then sets the duedate and onloan fields in the Video
class. The due date is printed on screen. There is a get method for the customer name.The constructor for the VideoStore class initialises a small number (less than 10) of Customer and
Video objects and stores them in two separate ArrayLists that are the instance fields for the class. It
provides a method (listallvideos()) for listing all the videos in the store and a method called
borrow(String,String) described below.The main method in VideoTest creates a VideoStore, then enters a loop that implements a menu:
"Menu: L-List, B-Borrow, Q-Quit". A Scanner picks up the letter entered and causes the desired
response. List, lists the titles of all the videos along with whether they are on the shelf or the due date
if they are on loan. Quit, drops out of the loop and exits the application. Borrow, asks first the
Customer's name, and then the title of the video he wishes to borrow and picks up responses with a
Scanner. These are then passed to the VideoStore borrow method as borrow(name,title).The VideoStore borrow method checks that the name and title match entries in the VideoStore arrays,
and identifies the Customer and Video objects they correspond to. The Customer
borrowvideo(Video v) method can then be called.
this is my VideoTest Class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assignement;
import java.util.*;
/**
*
* @author Harris
*/
public class VideotTest {
public static void main(String[] args)
{
VideoStore vs = new VideoStore();
Scanner sc = new Scanner(System.in);
String menuResponse;
do
{
System.out.println("Menu: L-list, B-borrow, Q-quit");
menuResponse = sc.nextLine();
if(menuResponse.equals("L"))
vs.listallvideos();
else if (menuResponse.equals("B"))
{
System.out.println("What is your name?");
String nameResponse = sc.nextLine();
System.out.println("What is the title of the video you want to borrow?");
String videoResponse = sc.nextLine();
// vs.borrow(nameResponse,videoResponse);
}
} while(!menuResponse.equalsIgnoreCase("Q"));
}
}
*****************************************************
this is my VideoStore Class
*****************************************************
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package assignement;
import java.util.*;
/**
*
* @author Harris
*/
public class VideoStore {
private String VideoName;
private String CustomersName;
private ArrayList<String> Videos = new ArrayList<String>();
private ArrayList<String> CustomersListe = new ArrayList<String>();
public VideoStore(){
VideoName = null;
CustomersName = null;
}
public VideoStore(String VidName, String CustName){
VideoName = VidName;
CustName = CustomersName;
Videos.add("Brave Heart");
Videos.add("Troy");
Videos.add("Shakspear In Love");
Videos.add("Green Mile");
Videos.add("Ice Age");
CustomersListe.add("Harris");
CustomersListe.add("John");
CustomersListe.add("Ricky");
CustomersListe.add("Mike");
CustomersListe.add("Robin");
}
public String getVideoName(){
return VideoName;
}
public String getCustomersName(){
return CustomersName;
}
public void listallvideos(){
for (int i = 0; i < Videos.size(); i++)
System.out.println(Videos.get(i));
}
}
***********************************************
the problem which I get is when I run VideoTest which is my main class by chosing L it dosnt not list my Videos list which is an Array list it goes back to the menu.
Anyone Can Help?
Thanks