Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

DPIT121 – Lab Exercise 3 Due: Week 4 lab In lab 3, you will continue on another iteration for the same scenario from lab 1 and 2. 1) Add these methods to your MobilePlan class: 0.25 marks - static...

1 answer below »
DPIT121 – Lab Exercise 3
Due: Week 4 la
In lab 3, you will continue on another iteration for the same scenario from lab 1 and 2.
1) Add these methods to your MobilePlan class: 0.25 marks
- static A
ayList filterByExpiryDate (A
ayList plans, MyDate date)
which filter a list of plans and creates a filtered list of plan that are expired by the given date. To do this add a new method Boolean isExpired( MyDate expiryDate) to your MyDate class, which compares the given date with the object and returns false if the date is before that given expiryDate or true it is after that date.
2) Add these methods to your User class: 0.75 marks: 0.25 marks for each method
- boolean createPersonalPlan( String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, String city )
creates a personal plan and adds it to the list of the user’s plans, returns false if the id is not unique. Create an object from PersonalPlan and call addPlan method to add it to the list
- boolean createBusinessPlan( String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, int numberOfEmployees , int ABN)
creates a business plan and adds it to the list of the user’s plans, returns false if the id is not unique. Create an object from BusinessPlan and call addPlan method to add it to the list
- A
ayList filterByExpiryDate (MyDate date)
filters the policies and returns a list of policies with the expiry date before the given date by calling the co
esponding static method inside MobilePlan
3) Write a class MobileCompnay with the following fields and methods: 2 marks. 0.1 mark for each method
XXXXXXXXXXString name;
· private A
ayListusers
list of all the users having a plan with the company
· private String adminUsername
· private String adminPassword;
· private int flatRate;
· Constructors, mutators (set methods) and assessors (get methods) if necessary
· boolean validateAdmin( String username, String password)
returns true if username and password matches the admin login details
· boolean addUser(User user)
adds the user to users list if userID is unique, if not returns false
· Boolean addUser(String name, int userID, Address address)
creates and adds the User to users list if userID is unique, if not returns false. Create a user object and reuse the addUser(User user) method
· User findUser(int userID)
finds the user with the given ID or returns null if user does not exist
· boolean addPlan (int userID, MobilePlan plan)
finds the user with the given userID by using findUser method and adds the plan to the user, unsuccessful if userID does not exist or policy is not unique
· MobilePlan findPlan (int userID ,int planID)
finds the mobile plan for the given userID and returns it. Returns null if userID does not exist or planID does not exist for the given user
· void printPlans(int userID)
prints the user information and all the plans for the given userID
· void print()
prints all the users and for each user all the plans by calling User. PrintPlans(int flatRate)
· String toString()
coverts the whole object to string ( including all the users and their plans). Hint: call toString() for users in a loop and concatenate them
· boolean createPersonalPlan(int userID, String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, String city )
finds the user with the given userID (by calling findUser) and calls the createPersonalPlan for that user. Returns false if the user does not exist or if User.createPersonalPlan returns false
· boolean createBusinessPlan( int userID, String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, int numberOfEmployees , int ABN) )
finds the user with the given userID (by calling findUser) and calls the createBusinessPlan for that user. Returns false if the user does not exist or if User.createBusinessPlan returns false
· double calcTotalPayments(int userID)
returns the total monthly payments for the given user
· double calcTotalPayments ()
returns the total payments for all the users in the company
· boolean mobilePriceRise (int userID, double risePercent)
calls mobilePriceRiseAll method for the given user. Returns false if user cannot be found
· void mobilePriceRise(double risePercent)
Raise the price of all mobile phones for all users in the company
· A
ayList allPlans ()
returns a list of all the plans in the company across all users
· A
ayList filterByMobileModel (int userID, String mobileModel)
find the user by calling findUser and calls filterByCarModel for the given user
· A
ayList filterByExpiryDate (int userID, MyDate date)
find the user by calling findUser and calls filterByExpiryDate for the given user
· A
ayList filterByMobileModel (String mobileModel)
filters all the policies in the company by mobileModel across all users. Iterate over a loop for all users and for each user call the filterByCarModel method and add all the results together for a global list including all users.
· A
ayList filterByExpiryDate (MyDate date)
filters all the plans in the company by ExpiryDate across all users. The same as above
4) Add this test code to your main: 2 marks
1- You have one user from lab 2. Create few more users and more polices and one mobileCompnay in your main
2- Login to the mobileCompany once successful and once not successful with proper prompting
3- Add users to the mobileCompany by using both versions of addUser() and at least once not successful with prompting
4- Add several polices to the users by calling addPlan (int userID, MobilePlan plan), at least once not successful with wrong userID and once with duplicate plan with prompting
5- Add several polices to some users by calling createPersonalPlan() and createBusinessPlan() , at least once not successful with wrong userID and once with duplicate plan ID with prompting
6- Ask customer to enter a userID and and print the user and all of his plans by using methods inside mobileCompany
7- Ask customer to enter a userID and planID and find a plan with the given planID for that userID by calling findPlan (int userID ,int policyID) and then print the plan.
8- Print all the users inside the mobileCompany
9- Raise the price of mobile phones for all users and plans by 10% and print the suers again
10- Print the total payments for a given userID by calling calcTotalPayments (int userID)
11- Print the total payments for all users in the company
12- Call allPolicies() for the mobilCompany and store it in an A
ayList and print the list by using MobilePlan.printPlans()
13- For a given userID and expiry date call filterByExpiryDate (int userID, MyDate date), store the filtered list and print the list by using MobilePlan.printPlans()
14- For a given mobile model call mobileCompany.filterByMobileModel (String mobileModel) and print the filtered list
15- Ask user to enter a date (year, month, and day) and call filterByExpiryDate (MyDate date) and print the filtered list
16- Find a user with the given ID (valid) and save it in a user object. Ask user to provide a new address and change the cu
ent address for the given user
Answered Same Day Aug 03, 2021

Solution

Aditya answered on Aug 05 2021
152 Votes
LabExercise3
uild.xml

Builds, tests, and runs the project LabExercise3.


LabExercise3
uild/classes/.netbeans_automatic_build
LabExercise3
uild/classes/.netbeans_update_resources
LabExercise3
uild/classes/main01/Address.class
package main01;
public synchronized class Address {
private int streetNum;
private String street;
private String subu
;
private String city;
public void Address(int, String, String, String);
public int getStreetNum();
public String getStreet();
public String getSubu
();
public String getCity();
public void setStreetNum(int);
public void setStreet(String);
public void setSubu
(String);
public void setCity(String);
public String toString();
}
LabExercise3
uild/classes/main01/BusinessPlan.class
package main01;
public synchronized class BusinessPlan extends MobilePlan {
protected int numberOfEmployees;
protected int ABN;
public void BusinessPlan(String, int, MobilePhone, int, int, MyDate, int, int);
public int getNumberOfEmployees();
public int getABN();
public void setNumberOfEmployees(int);
public void setABN(int);
public void print();
public String toString();
public double calcPayment(int);
}
LabExercise3
uild/classes/main01/Main01.class
package main01;
public synchronized class Main01 {
public void Main01();
public static void main(String[]);
public static void addPlan(User, MobilePlan);
}
LabExercise3
uild/classes/main01/MobileCompany.class
package main01;
public synchronized class MobileCompany {
private String name;
private java.util.A
ayList users;
private String adminUsername;
private String adminPassword;
private int flatRate;
public void MobileCompany(String, java.util.A
ayList, String, String, int);
public String getName();
public java.util.A
ayList getUsers();
public String getAdminUsername();
public String getAdminPassword();
public int getFlatRate();
public void setName(String);
public void setUsers(java.util.A
ayList);
public void setAdminUsername(String);
public void setAdminPassword(String);
public void setFlatRate(int);
public boolean validateAdmin(String, String);
public boolean addUser(User);
public Boolean addUser(String, int, Address);
public User findUser(int);
public boolean addPlan(int, MobilePlan);
public MobilePlan findPlan(int, int);
public void printPlans(int);
public void print();
public String toString();
public boolean createPersonalPlan(int, String, int, MobilePhone, int, int, MyDate, String);
public boolean createBusinessPlan(int, String, int, MobilePhone, int, int, MyDate, int, int);
public double calcTotalPayments(int);
public double calcTotalPayments();
public boolean mobilePriceRise(int, double);
public void mobilePriceRise(double);
public java.util.A
ayList allPlans();
public java.util.A
ayList filterByMobileModel(int, String);
public java.util.A
ayList filterByExpiryDate(int, MyDate);
public java.util.A
ayList filterByMobileModel(String);
public java.util.A
ayList filterByExpiryDate(MyDate);
}
LabExercise3
uild/classes/main01/MobilePhone.class
package main01;
public synchronized class MobilePhone {
private String model;
private mobileType type;
private int memorySize;
private double price;
public void MobilePhone(String, mobileType, int, double);
public String getModel();
public mobileType getType();
public int getMemorySize();
public double getPrice();
public void setModel(String);
public void setType(mobileType);
public void setMemorySize(int);
public void setPrice(double);
public void priceRise(double);
public void print();
public String toString();
}
LabExercise3
uild/classes/main01/MobilePhone.rs
LabExercise3
uild/classes/main01/MobilePlan.class
package main01;
public abstract synchronized class MobilePlan {
protected String userName;
protected int id;
protected MobilePhone handset;
protected int internetQuota;
protected int capLimit;
protected MyDate expiryDate;
public void MobilePlan(String, int, MobilePhone, int, int, MyDate);
public static java.util.A
ayList filterByExpiryDate(java.util.A
ayList, MyDate);
public String getUserName();
public int getId();
public MobilePhone getHandset();
public int getInternetQuota();
public int getCapLimit();
public MyDate getExpiryDate();
public void setHandSet(MobilePhone);
public void setInternetQuota(int);
public void setCapLimit(int);
public void setExpiryDate(MyDate);
public void setMobileModel(String);
public void setUserName(String);
public void print();
public String toString();
public abstract double calcPayment(int);
public static void printPlans(java.util.A
ayList);
public static double calcTotalPayments(java.util.A
ayList, int);
public void mobilePriceRise(double);
public static void mobilePriceRiseAll(java.util.A
ayList, double);
public static java.util.A
ayList filterByMobileModel(java.util.A
ayList, String);
}
LabExercise3
uild/classes/main01/mobileType.class
package main01;
final synchronized enum mobileType {
public static final mobileType ANDRIOD;
public static final mobileType IOS;
public static final mobileType WINDOWS;
public static mobileType[] values();
public static mobileType valueOf(String);
private void mobileType(String, int);
static void ();
}
LabExercise3
uild/classes/main01/MyDate.class
package main01;
public synchronized class MyDate {
protected int year;
protected int month;
protected int day;
public void MyDate(int, int, int);
public Boolean isExpired(MyDate);
public int getYear();
public int getMonth();
public int getDay();
public void setYear(int);
public void setMonth(int);
public void setDay(int);
public String toString();
}
LabExercise3
uild/classes/main01/PersonalPlan.class
package main01;
public synchronized class PersonalPlan extends MobilePlan {
protected String city;
public void PersonalPlan(String, int, MobilePhone, int, int, MyDate, String);
public String getCity();
public void setCity(String);
public void print();
public String toString();
public double calcPayment(int);
}
LabExercise3
uild/classes/main01/User.class
package main01;
public synchronized class User {
private String name;
private int userID;
private Address address;
private java.util.A
ayList plans;
public void User(String, int, Address);
public boolean createPersonalPlan(String, int, MobilePhone, int, int, MyDate, String);
boolean createBusinessPlan(String, int, MobilePhone, int, int, MyDate, int, int);
public java.util.A
ayList filterByExpiryDate(MyDate);
public String getName();
public int getUserID();
public Address getAddress();
public java.util.A
ayList getPlans();
public void setName(String);
public void setAddress(Address);
public void setCity(String);
public MobilePlan findPlan(int);
public boolean addPlan(MobilePlan);
public boolean addPlan1(java.util.A
ayList, MobilePlan);
public void print();
public String toString();
public void printPlans(int);
public double calcTotalPayments(int);
public void mobilePriceRiseAll(double);
public java.util.A
ayList filterByMobileModel(String);
}
LabExercise3/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
LabExercise3/nbproject
uild-impl.xml








































































































































































































Must set src.di
Must set test.src.di
Must set build.di
Must set dist.di
Must set build.classes.di
Must set dist.javadoc.di
Must set build.test.classes.di
Must set build.test.results.di
Must set build.classes.excludes
Must set dist.ja




































































































Must set javac.includes
































































































































No tests executed.























































































































































































































































Must set JVM to use for profiling in profiler.info.jvm
Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
















































































...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here