Design and Develop an Inventory System for Mobile Devices

Verified

Added on  2019/09/20

|3
|1548
|216
Report
AI Summary
The assignment requires designing and developing an inventory system for keeping track of mobile devices rented from labs in a college. The system should have classes such as MobileDevice, Lab, Labs, and others with specific methods and data structures. The goal is to develop Java classes for the business application using specific data structures and algorithms.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
1. Goals
The goals of these assignments are: (1) develop, and implement Java classes for a business application using
specific data structures and algorithms; (2) write code for testing the soundness and completeness of your
solution.
2. Tasks
Your project is to design and develop an inventory system for keeping track of mobile devices rented from labs
in a college.
We start with the assumptions: (1) labs have unique names and, (2) a lab can stockpile a variable number of
mobile devices. Furthermore, a unique name and a value tag (an integer with values between -100 and 100)
define a mobile device type. The same device type can be stored in more than one lab.
1. A lab receives a rent request for a device and a period of time
2. The period is defined by two dates: the request date and the due date.
3. If the device is part of lab’s inventory and the device is available, then the device is rented.
4. If the device is not part of lab’s inventory or the device is already rented, the request is sent to another lab. If
the request cannot be satisfied, then it is dropped.
5. There are no data structures such as queues, for keeping track of the requests. However, the inventory system
works based on the first-come, first-served principle.
A template of the required classes is given to you. Some methods are complete, some are partially implemented
and some have only the signature defined. You can find the project template on your online course web page. It
is the last course item called Assessments. On the assessment section scroll down for Assignment 2 link.
For example, the class MobileDevice has been defined as:
class MobileDevice {
String deviceName; // the device name
int valueTag; // an integer between -100 and 100
Lab lab; // the lab having this device it its inventory
RentSettings rs; // rent settings
...
// inner class
private class RentSettings {
private String rentDate; // date when the item is requested
private String dueDate; // date when the item must be returned
private boolean borrowed = false; // true if the item is rented
...
}
}
The most important method of MobileDevice class is
public boolean rentDevice(String rentDate, String dueDate, Lab lab) { ... }
The method takes three arguments: two strings dates for the renting period and a lab from where the device is
rented. If dates are not valid it creates DateFormatException and returns false. If rentDate > dueDate
throws RentPeriodException and returns false.
If no exceptions occur a RentSettings object must be created for the mobile device that is rented.
The DateFormatException and RentPeriodException are user-defined exceptions you have to create and
they are part of project template.
The class Lab has two fields: a lab name and a collection of devices stored in the lab (data structure Vector).
public class Lab implements MaxTagValue {

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
String labName; // lab name
Vector<MobileDevice> devices; // data structure that keeps all devices
...
}
public interface MaxTagValue {
/**
* The method returns an integer.
* The integer is the greatest value of all tagValues of the lab devices
*/
int findMaximumValueTag();
}
The most important method of Lab class is
public boolean rentRequest(MobileDevice wanted, String requestDate, String dueDate)
The method takes as arguments:
-The mobile device that needs to be rented
-The date when the device can be rented
-The date when the device must be returned to the lab
The method returns true, if the device can be rented from this lab, and false otherwise
The class Labs creates all the Lab objects and stores the devices in each lab.
public class Labs {
public Lab[] labs; // an array that stores all labs
public int numberOfLabs; // number of labs in collection
public Labs(int numberOfLabs) {
this.numberOfLabs = numberOfLabs;
labs = new Lab[numberOfLabs];
}
...
}
The devices definitions are read from a file with the following structure: device name, tag value.
For example a file named Newnham.txt contains lines that define four devices
Android,53
Android,25
Blackberry2,-95
iPhone,45
A lab object can be built from a file with the method.
public Lab buildLabFromFile(String labName, String fileName)
The most important method of Labs class is
public Lab rentDeviceAvailable(MobileDevice md, String requestDate, String dueDate) {
The method takes as arguments the mobile device that needs to be rented with the dates. It searches all labs for a
device that can be rented. It returns the Lab object where the device is available, if any. If all devices are rented
returns null.
There are other auxiliary classes that will help you to build the required functionality. For example the class
Helper contains static methods for date validation.
public class Helper {
public static boolean isValidDate(String date) {
boolean valid = true;
DateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
formatter.setLenient(false);
try {
formatter.parse(date);
} catch (ParseException e) {
Document Page
valid = false;
}
return valid;
}
The important classes of your project must have method such as: toString(), equals(), hashCode(). All
classes and methods must have javadoc documentation. The important classes are defined on codeboard.io
template.
In order to build and run a tailored personal project you solution must have a number of labs equal to your last
digit of your student ID. If this number is less than 2, than you have to have at least 2 labs. For instance, if your
student ID is 354874345 than your project must create 5 labs (two labs are given to you Seneca@York and
Newnham, so you have to create additional 3 labs).
Each lab you create must contain a number of devices equal to the second last digit of your student ID. If this
number is less than 4, you have to have at least 4 devices in each lab. You can work with as many devices as
you like.
Several implementation clarifications:
1. You can assume that files are properly formatted and any line contains device name, tag value. You do not have to validate, but
you can skip the lines that are no correctly structured.
2. The device is defined by a name and a tag value. The tag that is unique for a device with random values between -100 and 100.
You can assume that a device can appear more than once in a lab.
3. When you develop your solution be sure you DO NOT CHANGE the signatures of the given methods. However, you can add
new methods to enforce the behaviour defined by the project requirements.
To demonstrate your solution you have to write code to resolve the following tasks:
TASK 1
- build labs from files - at least two labs
- print lab and the devices from it
The device must be printed with the following format:
(device name, value tag) - if the device is not assigned to a lab, and
(device name, value tag => lab name) RentSettings (rent date, due date, lab name, borrowed) - if the device
belongs to a lab.
TASK 2
- ask for a device that is not in any lab inventory. For example, ask about a device that has the name
“Unknown”
TASK 3 - ask for a device that is in a lab inventory
- issue a rent request and print the device object
- issue the same rent request and print the device object
- return the device
- issue the rent request with new dates and print the device object
TASK 4 - ask for the same device in all labs
- look for the same device in all labs and return all the labs where the device is in the lab inventory
- look for the same device in all labs and return all the labs where the device is available to be rented.
TASK 5
- calculate the greatest value tag of all the devices from a lab
TASK 6
- inquire about a device: is it rented?, is it overdue?, could it be found in more than one lab?, when can it be
rented?
1 out of 3
circle_padding
hide_on_mobile
zoom_out_icon
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]