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 »
Hi this is my assignment of lab 3.. In lab 3 you will continue from lab 1 and 2 which you guys did for me this is simple 4 questions but I want same expert for this lab who did lab 1 and 2 for me so he/she can easily do this kindly make sure do it perfectly and submit to me on time and I'll share my student name and ID incase you need of it thanksSTUDENT NAME: AHMER NASIR
STUDENT ID: 6880101STUDENT EMAIL: [email protected]


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 ArrayList filterByExpiryDate (ArrayList 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 - ArrayList filterByExpiryDate (MyDate date) // filters the policies and returns a list of policies with the expiry date before the given date by calling the corresponding static method inside MobilePlan 3) Write a class MobileCompnay with the following fields and methods: 2 marks. 0.1 mark for each method - String name; · private ArrayListusers // 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 · ArrayList allPlans () // returns a list of all the plans in the company across all users · ArrayList filterByMobileModel (int userID, String mobileModel) // find the user by calling findUser and calls filterByCarModel for the given user · ArrayList filterByExpiryDate (int userID, MyDate date) // find the user by calling findUser and calls filterByExpiryDate for the given user · ArrayList 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. · ArrayList 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 ArrayList 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 current address for the given user
Answered 3 days AfterMar 22, 2021

Answer To: DPIT121 – Lab Exercise 3 Due: Week 4 lab In lab 3, you will continue on another iteration for the...

Valupadasu answered on Mar 25 2021
149 Votes
Address.java
Address.java
public class Address {
    private int streetNum;
    private String street;
    private String city;



    public Address(int streetNum, String street, String city) {
        this.streetNum = streetNum;
        this.street = street;
        this.city = city;
    }
    public int getStreetNum() {
        return streetNum;
    }
    public void setStreetNum(int streetNum) {
        this.streetNum = streetNum;
    }
    public String getStreet() {
        return street;
    }
    public void setStreet(String street) {
        this.street = street;
    }
    public String getCity() {
        return city;
    }
    public void setCity(String city) {
        this.city = city;
    }

    @Override
    public String toString() {
        StringBuffer addrObj = new StringBuffer();
        addrObj.append("Street No: ").append(getStreetNum()).append("\n")
        .append("Street name: ").append(getStreet()).ap
pend("\n")
        .append("City: ").append(city);

        return addrObj.toString();
    }


}
BusinessPlan.java
BusinessPlan.java
public class BusinessPlan extends MobilePlan{
    int numberOfEmployees;
    int ABN;

    public BusinessPlan(String userName, int id, MobilePhone handset, int internetQuota, int capLimit,
            int numberOfEmployees, int ABN) {
        super(userName, id, handset, internetQuota, capLimit);
        this.numberOfEmployees = numberOfEmployees;
        this.ABN = ABN;
    }
    @Override
    double calcPayment(int flatRate) {
        double price = 0;
        price += getHandset().getPrice()/24;
        price += getCapLimit()/10;
        price += getInternetQuota()*10;
        price += flatRate;

        if(this.numberOfEmployees > 10) {
            price += (this.numberOfEmployees-10)*50;
        }
        return price;
    }

    @Override
    public String toString() {
        String str = "";
        str += super.toString();
        str += numberOfEmployees + " : " + ABN + "\n";
        return str;
    }
    @Override
    public void print() {
    super.print();
    System.out.println(numberOfEmployees + " : " + ABN + "\n");
    }
}
MobileCompnay.java
MobileCompnay.java
import java.util.ArrayList;
public class MobileCompnay {
    String name;
    private ArrayList users = new ArrayList<>(); // list of all the users having a plan with the company
    private String adminUsername;
    private String adminPassword;
    private int flatRate;
    public MobileCompnay(String name, ArrayList users, String adminUsername, String adminPassword, int flatRate) {
        this.name = name;
        this.users = users;
        this.adminUsername = adminUsername;
        this.adminPassword = adminPassword;
        this.flatRate = flatRate;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public ArrayList getUsers() {
        return users;
    }
    public void setUsers(ArrayList users) {
        this.users = users;
    }
    public String getAdminUsername() {
        return adminUsername;
    }
    public void setAdminUsername(String adminUsername) {
        this.adminUsername = adminUsername;
    }
    public String getAdminPassword() {
        return adminPassword;
    }
    public void setAdminPassword(String adminPassword) {
        this.adminPassword = adminPassword;
    }
    public int getFlatRate() {
        return flatRate;
    }
    public void setFlatRate(int flatRate) {
        this.flatRate = flatRate;
    }
    public boolean validateAdmin(String username, String password) {
        return this.adminUsername.equals(username) && this.adminPassword.equals(password);
    }
    public boolean addUser(User user) {
        if (findUser(user.getUserID()) != null) {
            return false;
        }
        return getUsers().add(user);
    }
    public Boolean addUser(String name, int userID, Address address) {
        return addUser(new User(name, userID, address));
    }
    public User findUser(int userID) {
        for (User user : getUsers()) {
            if (user.getUserID() == userID) {
                return user;
            }
        }
        return null;
    }

    public boolean addPlan (int userID, MobilePlan plan) {
        User userObj = findUser(userID);

        if(userObj == null) {
            return false;
        }
        return userObj.addPlan(plan);
    }

    public MobilePlan findPlan (int userID ,int planID) {
        User userObj = findUser(userID);
        if(userObj == null) {
            return null;
        }

        return userObj.findPlan(planID);
    }

    public void printPlans(int userID) {
        User userObj = findUser(userID);
        if(userObj != null) {
            userObj.print();
        }
    }
    public void print() {
        for(User user : getUsers()) {
            user.print();
            user.printPlans(this.flatRate);
        }
    }

    public String toString() {
        StringBuffer output = new StringBuffer();
        for(User user : getUsers()) {
            output.append(user.toString()).append("\n");
        }

        return output.toString();
    }

    public boolean createPersonalPlan(int userID, String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, String city ) {
        User userObj = findUser(userID);

        if(userObj == null) {
            return false;
        }

        return userObj.createPersonalPlan(username, id, mobilePhone, internetQuota, capLimit, expiryDate, city);
    }

    public boolean createBusinessPlan( int userID, String username, int id, MobilePhone mobilePhone, int internetQuota, int capLimit, MyDate expiryDate, int numberOfEmployees , int ABN ){
        User userObj = findUser(userID);
        if(userObj == null) {
            return false;
        }

        return userObj.createBusinessPlan(username, id, mobilePhone, internetQuota, capLimit, expiryDate, numberOfEmployees, ABN);
    }

    public double calcTotalPayments(int userID) {
        User userObj = findUser(userID);
        if(userObj == null) {
            return 0.0;
        }
        return userObj.calcTotalPayments(this.flatRate);
    }

    public double calcTotalPayments () {
        double totPayments = 0.0;
        for(User user : getUsers()) {
            totPayments += user.calcTotalPayments(this.flatRate);
        }
        return totPayments;
    }

    public boolean mobilePriceRise (int userID, double risePercent) {
        User userObj = findUser(userID);
        if(userObj == null) {
            return false;
        }

        userObj.mobilePriceRiseAll(risePercent);

        return true;
    }

    public void mobilePriceRise(double risePercent) {
        for(User user : getUsers()) {
            user.mobilePriceRiseAll(risePercent);
        }
    }

    public ArrayList allPlans (){
        ArrayList allPlans = new ArrayList<>();

        for(User user : getUsers()) {
            allPlans.addAll(user.getPlans());
        }

        return allPlans;
    }

    public ArrayList filterByMobileModel (int userID, String mobileModel){
        User userObj = findUser(userID);
        if(userObj == null) {
            return null;
        }

        return userObj.filterByMobileModel(mobileModel);
    }

    public ArrayList filterByExpiryDate (int userID, MyDate date){
        User userObj = findUser(userID);
        if(userObj == null) {
            return null;
        }

        return userObj.filterByExpiryDate(date);
    }

    public ArrayList filterByMobileModel (String mobileModel){
        ArrayList allModelList = new ArrayList<>();

        for(User user : getUsers()) {
            allModelList.addAll(user.filterByMobileModel(mobileModel));
        }

        return allModelList;

    }

    public ArrayList filterByExpiryDate  (MyDate date){
        ArrayList planListByExpiryDate = new ArrayList<>();

        for(User user : getUsers()) {
            planListByExpiryDate.addAll(user.filterByExpiryDate(date));
        }

        return planListByExpiryDate;

    }
}
MobilePhone.java
MobilePhone.java
public class MobilePhone {
    private  String model;
    protected enum MobileType {Android, IOS, Windows};
    private MobileType type;
    public int memorySize;
    private double price;
    private MyDate expiryDate;

    public MobilePhone(String model, int memorySize, double price, MobileType type) {
        super();
        this.model = model;
        this.memorySize = memorySize;
        this.price = price;
        this.type = type;
    }



    public String getModel() {
        return model;
    }
    public void setModel(String model) {
        this.model = model;
    }
    public MobileType getType() {
        return type;
    }
    public void setType(MobileType type) {
        this.type = type;
    }
    public int getMemorySize() {
        return memorySize;
    }
    public void setMemorySize(int memorySize) {
        this.memorySize = memorySize;
    }
    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        this.price = price;
    }
    public MyDate getExpiryDate() {
        return exp...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here