the OOP project is needed to be coded in netbeans and store a information in fil
ID: 3855925 • Letter: T
Question
the OOP project is needed to be coded in netbeans and store a information in file on local machine it could be stored with xml tags since its easier.
OOP Project Description
Requirements:
You are to design and build software media rental system. The software will track each user’s account with its rentals. A user can rent multiple media of different type/genre and all that user’s rentals are managed under their account (single account per user). A user will be assigned a unique account id by the system and his first name, last name, and email address will also be stored at account creation. There will be ability to update the user’s name and email address but not the account id.
The software needs to be able to track different accounts, but the software should only load and actively manage one account at a time. There should be the ability to save account information to a file, re-open it later (one account per file using XML format), and delete the account (delete file with account information). The account id will be used as part of the filename to save, lookup to open, and delete account. There can be an account without any media rented.
There are 3 types of media that can be rented: Movie DVD, Music CD, and Audio Book CD. The company only rents certain genre of each media, shown in the table below. All media have following characteristics: media id (integer), title (String), year published (integer), file size in megabytes (double), rental end date (Calendar), and rental fee (Double). Audio book also has number of chapters (integer) and Music CD the length in minutes.
Media Type
Genre
Movie DVD
Romance
Drama
Documentary
Music CD
Country
Classical
Audio Book on CD
Memoir
SciFi
Romance
So for example, a user would rent a specific media such as a movie DVD of genre Romance with title “Love”, media id 100005, etc. Rental fee needs to be calculated at the time the rental is added to the account and the calculated fee should be stored in the rented media’s attribute.
Every media has a price to rent based on a 2 week rental. The following rules show how to determine the rental price.
Movie DVD rental has a flat fee of $3.50 for movie published within current year and otherwise a flat fee of $2.00. So for example if the DVD was published this year, it would cost $3.50 to rent for two weeks but if published last year, it would cost $2.00. However, Drama and Romance media has an additional fee of $0.25 added to the price so for documentary the above example would be $3.75 and $2.25 respectively.
Audio Book rentals are a little more complex.The rental price is calculated by multiplying the number of chapters * 0.10 and adding a $1 if the Audio Book was published this year. So if the Audio Book was published this year and the size is 20 chapters, the rental would cost $3.00 (20 * 0.10 + 1) and if it was published 2 years ago, it would be $2.00 to rent.
Music CDs are even more complicated because they depend of the type of music being rented. So classical rentals are calculated based on the file size * 0.015 and additional fee of 1.00 if published this year.Country music rental are calculated based on the file size * 0.02 and additional fee of 1.00 if published this year. So a classical music rental of size 114 MB published this year would cost $2.71 (114 *0.015 +1) and country music rental of 114 MB published this year would cost $2.28 (114 *0.02).
There also needs to be ability to add a media to the account, and delete media from the account. When a rental expires, it can be renewed for another two weeks.
Here is a scenario how this system should work in a real business:
Imagine there are media boxes on the shelf in some rental place. So a customer comes in and gets some boxes of the rentals they want to get. They go up to the cashier and if it is their first time, an account will be created for them in the system. They will need to provide their first name, last name and email address that will be inputted by the cashier into the new account being created. The system will generate an account id for this user and cashier will give that information to the customer.
Then the cashier will scan each box for the media information, which will create the media object in the system. That object will be added to the account. The cashier will repeat for each media box to be rented. The rental end date will be set by the system, 2 weeks from the current date. The system will calculate the rental fee for each media being rented. All that information will be displayed on the screen: each media with its information and the rental fee for each (the actual displaying will be done by user interface which is not part of the system you are creating). Customer will pay and get receipt but that is outside of the scope of the system we are creating.
Then the customer may come in to return the media. He will provide his account number and the cashier will bring his account up. The cashier will select return choice in the user interface and scan each media to remove from his account. Let’s say he had 3 media rented but he is returning two of them. So those 2 rentals are removed from his account. For the one he still has he decides to renew it so cashier selects renew option in the user interface, scans the media and that media gets renewed for next two weeks. Again the fee is calculated and all the new information in the account is displayed by the user interface.
Then he notices on the screen that his name is spelled incorrectly or his email is not right. The cashier will be able to change that information in the account.
Next time when customer comes in, he may return the media he has but he may not want to rent at this time. His account will be still there but without any media until next time when he rents again.
The system you are designing will have the functionality needed to satisfy the above requirements as illustrated by the scenario. You will not be implementing the actual user interface (you will still design them though in assignment 7) but you need the classes, attributes, and methods to receive and provide the information that the user interface will need. You can assume that for a complete solution there would be some other class that implements user interface with main() method and the scanning module and that it will call your classes. You will write such a class with main() in assignment 8 as your test class.
Media Type
Genre
Movie DVD
Romance
Drama
Documentary
Music CD
Country
Classical
Audio Book on CD
Memoir
SciFi
Romance
Explanation / Answer
@Override
public Action[] getActions(boolean arg0) {
return new Action[]{
CommonProjectActions.newFileAction(),
CommonProjectActions.copyProjectAction(),
CommonProjectActions.deleteProjectAction(),
CommonProjectActions.customizeProjectAction(),
CommonProjectActions.closeProjectAction()
};
}
@Override
public Lookup getLookup() {
if (lkp == null) {
lkp = Lookups.fixed(new Object[]{
this,
new Info(),
new CustomerProjectLogicalView(this),
new CustomizerProvider() {
@Override
public void showCustomizer() {
JOptionPane.showMessageDialog(
null,
"customizer for " +
getProjectDirectory().getName());
}
},
});
}
return lkp;
}
package org.customer.project;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.netbeans.api.project.ProjectUtils;
import org.netbeans.spi.project.ui.CustomizerProvider;
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
import org.openide.awt.StatusDisplayer;
import org.openide.util.lookup.Lookups;
public class CustomerCustomizerProvider implements CustomizerProvider {
public final CustomerProject project;
public static final String CUSTOMIZER_FOLDER_PATH =
"Projects/org-customer-project/Customizer";
public CustomerCustomizerProvider(CustomerProject project) {
this.project = project;
}
@Override
public void showCustomizer() {
Dialog dialog = ProjectCustomizer.createCustomizerDialog(
//Path to layer folder:
CUSTOMIZER_FOLDER_PATH,
//Lookup, which must contain, at least, the Project:
Lookups.fixed(project),
//Preselected category:
"",
//OK button listener:
new OKOptionListener(),
//HelpCtx for Help button of dialog:
null);
dialog.setTitle(ProjectUtils.getInformation(project).getDisplayName());
dialog.setVisible(true);
}
private class OKOptionListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
StatusDisplayer.getDefault().setStatusText("OK button clicked for "
+ project.getProjectDirectory().getName() + " customizer!");
}
}
}
@Override
public Lookup getLookup() {
if (lkp == null) {
lkp = Lookups.fixed(new Object[]{
this,
new Info(),
new CustomerProjectLogicalView(this),
new CustomerCustomizerProvider(this)
});
}
return lkp;
}
package org.customer.project.panels;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
import org.netbeans.spi.project.ui.support.ProjectCustomizer.Category;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
public class GeneralCustomerProperties
implements ProjectCustomizer.CompositeCategoryProvider {
private static final String GENERAL = "General";
@ProjectCustomizer.CompositeCategoryProvider.Registration(
projectType = "org-customer-project", position = 10)
public static GeneralCustomerProperties createGeneral() {
return new GeneralCustomerProperties();
}
@NbBundle.Messages("LBL_Config_General=General")
@Override
public Category createCategory(Lookup lkp) {
return ProjectCustomizer.Category.create(
GENERAL,
Bundle.LBL_Config_General(),
null);
}
@Override
public JComponent createComponent(Category category, Lookup lkp) {
return new JPanel();
}
}
public class ReportsSubprojectProvider implements SubprojectProvider {
private final CustomerProject project;
public ReportsSubprojectProvider(CustomerProject project) {
this.project = project;
}
@Override
public Set<? extends Project> getSubprojects() {
return loadProjects(project.getProjectDirectory());
}
private Set loadProjects(FileObject dir) {
Set newProjects = new HashSet();
FileObject reportsFolder = dir.getFileObject("reports");
if (reportsFolder != null) {
for (FileObject childFolder : reportsFolder.getChildren()) {
try {
Project subp = ProjectManager.getDefault().
findProject(childFolder);
if (subp != null && subp instanceof ReportsSubProject) {
newProjects.add((ReportsSubProject) subp);
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
} catch (IllegalArgumentException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return Collections.unmodifiableSet(newProjects);
}
@Override
public void addChangeListener(ChangeListener cl) {
}
@Override
public void removeChangeListener(ChangeListener cl) {
}
}
@NodeFactory.Registration(projectType = "org-customer-project", position = 20)
public class ReportsSubProjectNodeFactory implements NodeFactory {
@StaticResource()
public static final String SUB_ICON = "org/customer/project/sub/icon.png";
@Override
public NodeList<?> createNodes(Project project) {
ReportsSubprojectProvider rsp = project.getLookup().
lookup(ReportsSubprojectProvider.class);
assert rsp != null;
return new ReportsNodeList(rsp.getSubprojects());
}
private class ReportsNodeList implements NodeList<Project> {
Set<? extends Project> subprojects;
public ReportsNodeList(Set<? extends Project> subprojects) {
this.subprojects = subprojects;
}
@Override
public List<Project> keys() {
List<Project> result = new ArrayList<Project>();
for (Project oneReportSubProject : subprojects) {
result.add(oneReportSubProject);
}
return result;
}
@Override
public Node node(Project node) {
FilterNode fn = null;
try {
fn = new FilterNode(DataObject.find(node.
getProjectDirectory()).getNodeDelegate()){
@Override
public Image getIcon(int type) {
return ImageUtilities.loadImage(SUB_ICON);
}
@Override
public Image getOpenedIcon(int type) {
return ImageUtilities.loadImage(SUB_ICON);
}
};
} catch (DataObjectNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
return fn;
}
@Override
public void addNotify() {
}
@Override
public void removeNotify() {
}
@Override
public void addChangeListener(ChangeListener cl) {
}
@Override
public void removeChangeListener(ChangeListener cl) {
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.