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

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 »
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 li
ary 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 subu
;
- 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(A
ayList 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 Li
ary lecture code.
- static double calcTotalPayments (A
ayList 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(A
ayList 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 A
ayList filterByMobileModel (A
ayList 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 Li
ary 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
· A
ayList 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 Li
ary example
· MobilePlan findPlan (int planID)
finds the plan and returns it. Returns null if planID does not exist. See findBook() and findUser() methods in Li
ary 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 co
esponding static method inside MobilePlan
· double calcTotalPayments (int flatRate)
returns the total monthly payments for this user by calling the co
esponding static method inside MobilePlan
· void mobilePriceRiseAll (double risePercent)
calls the co
esponding static method inside MobilePlan to increase the mobile phone (handset) price for all the plans the user owns
· A
ayList filterByMobileModel (String mobileModel)
filters the plans and returns a list of plans with the handset (mobilePhone) model containing the given mobileModel by calling the co
esponding 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 e
or 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 After Mar 15, 2021

Solution

Valupadasu answered on Mar 17 2021
171 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;
    }
    
    @Ove
ide
    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;
    }
    @Ove
ide
    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;
    }
    
    @Ove
ide
    public String toString() {
        String str = "";
        str += super.toString();
        str += numberOfEmployees + " : " + ABN + "\n";
        return str;
    }
    @Ove
ide
    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;
    }
    @Ove
ide
    public String toString() {
        return this.model + " : " + type + " : " + memorySize + "GB : Rs." + price;
    }
}
MobilePlan.java
MobilePlan.java
import java.util.A
ayList;
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