DPIT121 – Lab Exercise 2 Due: Week 3 lab In lab 2, you will continue on the same scenario from lab 1 to improve it. The improvement in term of software engineering is called Iteration. So you are...

1 answer below »
Hi this is my lab 2 assignment you did the lab 1 assignment for me this is continue part for that one if you remember I asked you about the expert name because I told you that It wil be continue so it will be easy for you guys to do all my assignments


DPIT121 – Lab Exercise 2 Due: Week 3 lab In lab 2, you will continue on the same scenario from lab 1 to improve it. The improvement in term of software engineering is called Iteration. So you are working on another iteration of Mobile Provider Company System. Study week 2 lecture codes (Both bank and library examples) in depth before attempting this lab. Also watch Lab 2 Recorded Tutorial: 1) Add a new class MyDate with these attributes: 0.25 marks - int year; - int month; - int day; Add a field to your MobilePlan class to store the expiry date for the plan: - MyDate expiryDate; 2) Add a new class Address with these attributes: 0.25 marks - int streetNum; - String street; - String suburb; - String city; 3) Add mutators (set methods), and assessors (get methods) to your MobilePhone, MyDate, Address, and MobilePlan classes. 4) Add these methods to your MobilePlan class: 1.5 marks: 0.3 marks for each method - static void printPlans(ArrayList plans) // prints a list of plans. You had this in your main ( ) in lab 1. Move it to this method. Study printAccounts in Bank lecture code or printBooks or printUsers in Library lecture code. - static double calcTotalPayments (ArrayList plans, int flatRate) //calculates the total monthly payments for a list of plans. You had this in your main ( ) in lab 1. Move it to this method. Study calcTotalBalance in Bank lecture code. - void mobilePriceRise(double risePercent) // It has one parameter, a price rise in percent. The method increases the plan’s handset.price by rise percent. (e.g., 0.1 as rise percentage means the mobile price to be increased by 10% i.e., ). Bad Design: You can call MobilePhone setPrice and getPrice methods for plan’s handset to do it as below: handSet.setPrice(handSet.getPrice()*(1+risePercent); Good Design: Add a new method priceRise(double rise) to MobilePhone and call this method in mobilePriceRise - static void mobilePriceRiseAll(ArrayList plans, double risePercent) // calls the mobilePriceRise method for all the plans in a given list ( in a for each loop). This is to increase the price of handsets for all plans in a list. - static ArrayList filterByMobileModel (ArrayList plans, String mobileModel) // which filter a list of plans and creates a filtered list of plans, all with the given handset model . See filterByName and filterByAuthor in Library example. 5- Write a class User with the following fields and methods: 1.5 marks · private String name; // the name of the account holder · private int userID; // the user ID/number · private Address address; // you need to define the Address class as described · ArrayList plans // list of all the Mobile Plans this user holds · Constructor, mutators (set methods) and assessors (get methods) if necessary and not for all fields. · boolean addPlan (MobilePlan plan) // adds a plan, returns true if successful (when planID is unique) and returns false if not. See addBook() and addUser() methods in Library example · MobilePlan findPlan (int planID) // finds the plan and returns it. Returns null if planID does not exist. See findBook() and findUser() methods in Library example · void print() // prints all the information of this user including all the plans information · String toString() // converts the user and his/her plans to String · void printPlans(int flatRate) // prints all the plans this user owns as well as the monthly payment for each plan by calling the corresponding static method inside MobilePlan · double calcTotalPayments (int flatRate) // returns the total monthly payments for this user by calling the corresponding static method inside MobilePlan · void mobilePriceRiseAll (double risePercent) // calls the corresponding static method inside MobilePlan to increase the mobile phone (handset) price for all the plans the user owns · ArrayList filterByMobileModel (String mobileModel) // filters the plans and returns a list of plans with the handset (mobilePhone) model containing the given mobileModel by calling the corresponding static method inside MobilePlan 6- Add this test code to your main: 1.5 marks: 0.1 marks for each test item excluding creating the plans - Create few personal and business plans and one user in your main. - Add the plans to the user by using addPlan( ) - call the print method for the user (note that user.print ( ) also prints all the plans) - print the user by using toString() (Note that toString includes all the plans’ details in addition to user information) - Find a plan by using findPlan() for a given plan ID when the ID is not valid and show an error message: “Plan has not been found” - Find a plan by using findPlan() with a given plan ID (valid) and save it in a plan object to be used for following steps. - print this plan, call mobilePriceRise with 0.1 rise for this plan and print it again - change the userName of this plan to “Robert” by using setUserName(String newName) - change the mobile/handset model of this plan to “Iphone X” by using Plan.SetMobileModel(String model) which calls MobilePhone.setModel(String model) - change the city of the user to “Wollongong” by using User.SetCity(String city) which calls Address.setCity(String city) - ask the customer to enter the information for a new address (by using Scanner) and change the address of the user by using setAddress(address) and print the user after change. - print the total monthly payments for all plans this user owns - add 10% to the price of mobile phones for all the plans this user owns - print the total monthly payments for all plans this user owns again - ask the customer to enter a mobileModel then call filterByMobileModel method for the user and store the filtered list. - print the filtered list by calling the static method inside MobilePlan
Answered 1 days AfterMar 15, 2021

Answer To: DPIT121 – Lab Exercise 2 Due: Week 3 lab In lab 2, you will continue on the same scenario from lab 1...

Valupadasu answered on Mar 17 2021
168 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;
    }
    pub
lic 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()).append("\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");
    }
}
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 expiryDate;
    }
    public void setExpiryDate(MyDate expiryDate) {
        this.expiryDate = expiryDate;
    }
    @Override
    public String toString() {
        return this.model + " : " + type + " : " + memorySize + "GB : Rs." + price;
    }
}
MobilePlan.java
MobilePlan.java
import java.util.ArrayList;
import java.util.stream.Collectors;
public abstract class MobilePlan {
    private String userName;
    private int id;
    private MobilePhone handset;
    private int internetQuota;
    private int capLimit;
    public String getUserName() {
        return userName;
    }
    public void setUserName(String userName) {
        this.userName = userName;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public MobilePhone getHandset() {
        return handset;
    }
    public void setHandset(MobilePhone handset) {
        this.handset = handset;
    }
    public int getInternetQuota() {
        return internetQuota;
    }
    public void setInternetQuota(int internetQuota) {
        this.internetQuota = internetQuota;
    }
    public int getCapLimit() {
        return capLimit;
    }
    public void setCapLimit(int capLimit) {
        this.capLimit = capLimit;
    }
    public MobilePlan(String userName, int id, MobilePhone handset, int internetQuota, int capLimit) {
  ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here