954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to edit a particular loan?...

hi i am trying to create a dvd rental system, up till now i have entered the client's details into an array list and have created a loan for every client that rented a dvd. But now i need to edit a part of this loan, for eg i need to change the dvd title of this loan. can you please help me in trying to do so?( i need to ask the user to input the new dvd title to replace the old one.). The methodclass contains the setters and getters.

methodclass c = new methodclass();
            System.out.println("");
            System.out.println("Please enter the DVD title you want to rent.");
            String dvdtitle = sc.next();
            c.setDVDTitle(dvdtitle);
            LoanList.add(c); 
            System.out.println("Please enter your name.");
            String name = sc.next();
            c.setName(name);
            LoanList.add(c);
            System.out.println("Please enter your surname.");
            String surname = sc.next();
            c.setSurname(surname);
            LoanList.add(c);
friknos
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

hi i am trying to create a dvd rental system, up till now i have entered the client's details into an array list and have created a loan for every client that rented a dvd. But now i need to edit a part of this loan, for eg i need to change the dvd title of this loan. can you please help me in trying to do so?( i need to ask the user to input the new dvd title to replace the old one.). The methodclass contains the setters and getters.

methodclass c = new methodclass();
            System.out.println("");
            System.out.println("Please enter the DVD title you want to rent.");
            String dvdtitle = sc.next();
            c.setDVDTitle(dvdtitle);
            LoanList.add(c); 
            System.out.println("Please enter your name.");
            String name = sc.next();
            c.setName(name);
            LoanList.add(c);
            System.out.println("Please enter your surname.");
            String surname = sc.next();
            c.setSurname(surname);
            LoanList.add(c);


Take a look at the java docs: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html , especially the set() method which will replace a value: "set(int index, Object element)
Replaces the element at the specified position in this list with the specified element."

DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

@cOrRuPtG3n3t!x please use links to the current Java6/Java7 API's, because in most of them were important changes in nested on inherits methods however +1 for simple and clear suggestion

mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224
 
@cOrRuPtG3n3t!x please use links to the current Java6/Java7 API's, because in most of them were important changes in nested on inherits methods however +1 for simple and clear suggestion


Yes sorry i never even saw the version but i do understand current documentation is always a the better choice, wont make that mistake again :)...

@OP here is the newer java 7 docs: http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

[EDIT]
lol yup Ezzaral, thats actually exactly how it happened-was my first google result :P

DavidKroukamp
Practically a Master Poster
Team Colleague
693 posts since Dec 2011
Reputation Points: 282
Solved Threads: 169
 

The Java 1.4.2 docs do seem to come up near the top of search results fairly often, so it's an easy mistake to make if you don't glance at the version.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

ok then thanks for your help :)

friknos
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: