ICT162: Implement the Customer class The Customer class Models one Customer It has Two Instance Variables: Object Oriented Programming Assignment, SUSS, Singapore

University Singapore University of Social Science (SUSS)
Subject ICT162: Object Oriented Programming

Question:1

(a) Implement the Customer class. The Customer class models one customer. It has two instance variables: _name and _contact and a constructor initialise both variables. There are getter methods for the instance variables and a setter method for _contact. The _str_method returns a string representation of a Customer object. An example string is shown here: Peter 99998888

(b) Implement the Staycation class. The Staycation class models one staycation that can be booked. It has four instance variables: hotelName, _nights, _cost and _voucherAllowed, and a constructor. initializes all four variables with the fourth variable, _voucherAllowed set to a default value True. There are getter methods for all instance variables and setter methods for _cost and _voucherAllowed. The method costPerNight returns the cost of the stay per night, and the method is cheaper returns True if this staycation costs less per night than the other staycation.

The _str_method returns a string representation of a Staycation object. Two example strings are shown here:

Grand Marina Nights: 2 Current Price: $398 or $199.00 per night Voucher allowed: No

Hotel Bugis Nights: 1 Current Price: $168 or $168.00 per night Voucher allowed: Yes

(c) Implement the Booking class. The Booking class models on booking made by a customer for a staycation. It has four instance variables: _customer. _staycation. _checklnDate and _cost. and a constructor initialises all four variables with the fourth variable. _cost set to the cost of the staycation at the time of booking. Once a booking is made, the cost will not be affected by any change made to the cost of the staycation.

The method costDifferenceFromCurrent returns the difference between the cost at the time of booking and the current cost of the staycation. There are getter methods for all instance variables, including a method to return the name of the hotel and to return the check-out date based on the number of nights the staycation is for and the check-in date. The _str_method returns a string representation of a Booking object. An example string is shown here:

Hire a Professional Essay & Assignment Writer for completing your Academic Assessments

Native Singapore Writers Team

  • 100% Plagiarism-Free Essay
  • Highest Satisfaction Rate
  • Free Revision
  • On-Time Delivery

Grand Marina Nights: 2 Current Price: $3913 or $199.00 per night Voucher allowed: No Wk.) at $100 Chock-in Date: 30 2un 2021 Check-out Gate: 02 Jul 2022 Peter 999988U

((l) (i) Create a Customer object with the details: Peter «Kassa. Change the contact number to 099901344.

(ii) Create two Staycation objects, and then update the necessary instance variables so that printing them results in the strings: Grand Marina Nights: 2 Current Price: $398 or $199.00 For.

night Voucher allowed: No Motel Bees Nights: 1 Current Price: 3168 or $168.00 per

night Voucher allowed: Yes Display whether the first staycation is cheaper than the second.

(iii) Create a Booking object with the details: Grand Marina Might,: 2 Current Price: $390 Or $199.00 per night Voucher allowed: Booked at: $1911 Chock-in Date: 30 Jun 2021 Chock-out Date: 02 tut 2021 Peter 9999Se Using the reference to the Booking object. update the cost of staycation to $438.

Show that the cost in the booking is still $398, and then print the cost difference.

Question 2 Define classes for a library, and test the classes. Refer to the class diagram in Figure

(a) Implement the Item class. The Item class models one item in a library. It is an abstract superclass. It has one class variable: _loanDuration set to 14 days. and getter and setter class methods for the class variable. There are three instance variables: title, _yeatPublished and _cost. A constructor initialises all instance variables, assuming a title is unique. There are getter methods for all instance variables.

There are two abstract methods, getFinesPerDay and getAdminCharge that returns the administrative charge. The method lostCharges returns the sum of administrative charges and the cost of the item. The _str_method returns a string representation of an Item object. An examole string is shown here: Asia Food en1 Cultwe 2019 Cost: $31)

(b) Implement the Book and Media classes. The Book and Media classes model a book and a media respectively, available in a library. They are subclasses of Item.

The Book class has an additional instance variable: _authors, a list of string, each string for the name of one author. The administrative charge is computed using a decreasing percentage of the book cost, and the decrease is based on the year of publication. For a book that is older than 9 years from the year of publication using today’s date, the percentage is 10%. For younger books, use this fonnula to compute the percentage:

The fine per day is 50.25. The str returns a string representation of a Book object. An example string is shown here: The Road to forget 2020 Cost: $35 By Justin Grave, Ton Splesson The Media class has one class variable: JoanDuration set to 3 days. It has no additional instance variable. The administrative charge is 1.5 times the cost of the media. and the fine per day is 52.50.

(c) Implement the ItemCopy class. The Item class model a copy of an item in the library. e.g., a book or a media that a member can borrow. It has a class variable: _nextld used for generating running numbers. There are three instance variables: _item. _copyld and _available. The constructor initialises all three instance variables with _copyld set to a number generated using _nextld, and _available set to True as a new item copy is available when first created.

There are getter methods for all instance variables, and a setter method for _available to set the item copy to be available (True) when the copy item is returned, and to set the item copy to unavailable (False) when the copy item is borrowed. The _str_ returns a string representation of a ItemCopy object. Three example strings are shown here (Note that there are two copies for the book with title. The Road to forget):

Copyld: 1 The Road to Forget 2020 Cost: $35 By Justin Grave, Ton Aplesson Available: True

Copyld: 2 Asia Feed and Culture 3019 Cost: $30 Available: False

Copyld: 3 The Road to Forget 2020 Cost: $35 By Justin Grave, Ton Aplesson Available: False

(d) Implement the Loan class. The Loan class models a loan made for a copy of an item. It has three instance variables: _itemCopy. _dueDate and _retumDate, and a constructor initialises all three variables with _dueDate set to the loanDate added with the loan duration based on type of item being borrowed (e.g. Book or Media). _retumDate is set to None, and the borrowed item copy set to unavailable.

There are getter methods for dueDate and _returnDate. including methods. loanTitle and copyld to return respectively. the tide and the copyld borrowed. There is a setter method for _retumDate. The setter method also set the itemCopy to become available. A method, renew updates _dueDute (the current due date added with the loan duration) if the date on which the renew is made is not after _dueDate.

The method returns True if the renewal is successful, and False otherwise. The method getFines returns the fines incurred. If the item has not been returned, the method returns -I. The method losiCharges returns the charge if the borrowed item is lost.

The _str_method returns a string representation of a Loan object. Two example strings are shown here:

Lean copy 10: 3 The Road to Forget One date: 29 Mar 2021 Return co: On Loan Loan Copy 10: 3 The Road to kept One date: 29 Mar 2021 Return co: 17 Mar 2021

Buy Custom Answer of This Assessment & Raise Your Grades

Question 3 is a continuation of Question 2. Refer to the class diagram in Figure

Q3. (a)
(i) Implement a subclass, LibraryExeeption of the Exception class. This class has no additional variable or method. When the application encounters a business rule violation, an exception from this class is rained.

(ii) Implement a subclass LibraryPaymentException of the LibraryException class. This class has an additional instance variable, _amount. The constructor initialises the amount. There is a getter method. When the application encounters a business rule violation involving a payment amount, an exception from this class is raised.

(b) (i) Implement the Member class. Thc Member class models a library member. It has a class variable, _loanQuota set to 4, and a class method to return the loan quota. There are four instance variables: _memberld. _name. _amountOwed and _loans. and a constructor initialises all four variables with _ amountOwed set to 0. and _loans set to an empty list.

There are getter methods for _membcrld and _amountOwed, including methods, pastLoans and presentLoans to return a list of the loans with returned items, and the loans with unretumed items, respectively. If a title is provided to past Loans and presentLoans, the methods returns only loans with matching title.

The method countCurrentLoan returns the number of loans with unreturned items, and the method quotaReached returns True if the count of the current loan is at the loan quota. The method returns False otherwise.

A method searchLoanFor returns the first loan with an unreturned item with a matching title as the parameter. If there is no such loan. the method returns the last returned loan with a matching title. Otherwise. the method returns None.

A method borrowItem raises an exception under the following conditions:

• The provided copyltem is not available (already borrowed out). The exception message contains the details of the copy, and that it is unavailable.

• The member’s loan quota is already reached. Thc exception message is the loan quota has been reached.

• The member has outstanding fines. Thc exception raised includes both I) the amount owed. and 2) a message that the member needs to pay an outstanding fine first. If no exception is raised, a loan is created and added to the member. The method returns True.
A method renew raises an exception under the following conditions:

• The provided title does not have a match in the list of loans. The exception message is that there is no loan recorded for the title.

• The provided title does not have a match in the list of current loans. Instead it matches a past loan. The exception message includes the title of the item and that it has been returned on the date, retrieved from the past loan.

• The provided title has a match in the list of current loans, but the renew date is past the due date. The exception message includes the due date of the item and the date that the renew is requested on. If no exception is raised when the loan is renewed, the method returns True.

A method returnitent raises an exception under the following conditions:

• The provided title does not have a match in the list of loans. The exception message is that there is no loan recorded for the title.

• The provided title does not have a match in the list of current loans. Instead it matches a past loan. The exception message includes the title of the item and that it has been returned on the date, retrieved from the past loan.

If no exception is raised the loan is updated with the return date. If there is a fine incurred, the amount is added to the member. The method returns True.

A method pay raises an exception if the parameter amount (the amount the member intends to pay) is not more than 0. The exception message includes the amount owed as well as that the amount should be greater than 0. If no exception is raised, the amount owed by the member is updated. In general, the amount paid need not be the full amount owed. The method returns 0 if there is no change (amount paid—amount owed). Otherwise, it returns the change.

A method loanStr returns a string representation of the loans the member has, if no loan list is provided. Otherwise, it returns a string representation of the loans in the provided loan list. An examole string returned is shown here:

Loan Copy Id: 1 The Road To Forget One date: IS Mar 1021 Return Co: On loan Loan Copy Id: 3 Asia Food And Culture One date: 04 Mar 2021 Return co: On Loan Loan Copy id: 8 Pcooerpoint Presentation Tips Oue date: 04 Mar 2021 Return co: On Loan

The _str_method returns a string representation of a Member object. Two example strings arc shown here:

Id: 5223 3Cl SOSO

Past Loans:

No past loan Present Loans:

no Outstanding loan

Outstanding loans: 0

(c) Implement the Library class. The Library class models a library. There are three instance variables: _members. _items and _copyltems, and a constructor initialises _members. _items to empty dictionaries, and _ copyltems to an empty list.

The method addltem adds an item to_items if the title does not exist and returns True. Otherwise, the method returns False. The method addCopyltem creates a copy item and adds to copyltems. The method registerMember adds a member to _members. if the member id does not exist, and returns True. Otherwise, it returns False.

The method removeMember removes a member with the provided member id. and returns the member. If there is no member with a matching member id. the method returns None.

The method searchMember returns a member with the provided member id. If there is no member with a matching member id, the method returns None. The method scarch(opyltem returns a copyltern with the provided copy id. If there is no copy item with a matching copy id, the method returns None.The method getAvailableCopyltems returns a list of copy items currently available for loan.

The method copyltemStr returns a string representation of copyltems if no copy item list is provided. Otherwise, it returns a string representation of the provided copy list. The method memberStr returns a string representation of _members. The method itemStr returns a string representation of items. The _str_method returns a string representation of a Library object. An example string is shown here:

Question 4.

Implement a GUI for managing staycations and bookings. The GUI records the staycations in a dictionary.

The bookings are recording in a list Stan the list empty.

The initial GUI is shown in Figure Q4a. All the text fields and the scrolltext arc not editable and there is no radio button that is selected. All three buttons arc clickable. The scrolltext displays all messages from event handling.

(a) Implement the GUI as shown in Figure Q4a. The title of the GUI MUST include your name.

b. You do not need to handle ValueError exceptions for this question. Implement event handling for the 2 radio buttons and 3 buttons.

Booking radio button This enables the two textfields on the left panel. All textfields should be clear.

Staycation radio button This enables the four textfields on the right panel. All textftelds should be clear.

If none of the radio button is selected and when any of the 3 buttons: Add. Remove and Display is clicked, display an error message: Select either Booking or Staycation first.

• Add button

With Booking dio button selected

– Both textfields must be entered. Otherwise, display an error message:

Please complete all the fields – If the staycation code cannot be located in the dictionary, display an error message: Invalid staycation code. – If the staycation code is valid, add an entry in the form Istaycation code, customer id) to the list and display the mmsage.

Added a booking. Clear the textlields for this case. With Staycation mho button selected – All four textfields must be entered.

Otherwise, display an error message: Please complete all the fields– If the staycation code already exists in the dictionary, display an error message: This code belongs to an existing staycation.

Check the input. – Otherwise, add an entry to the dictionary, and display the message: Added a staycation. Clear the textfields for this case

• Remove button

With Bookingsadio button selected – Both textfields must be entered. Othetwisc, display an error message: Please complete all the fields – Search the list for an entry with a matching staycation code and customer id, and remove only the first entry.

If an entry is removed, display the message: Removed a booking. Clear the text fields for this case. – If there is no matching entry, display the error message: No matching booking to remove.

Check the input. With the Staycation radio button selected – All four text fields must be entered. Otherwise, display an error message. Please complete all the fields – If the staycation code does not exist in the dictionary, display an error message: This code does, not belong to an existing staycation.

Buy Custom Answer of This Assessment & Raise Your Grades
.

Get Help By Expert

Most Singapore students struggle while doing ICT162: Object-Oriented Programming Assignment. They often ask ‘How to write a good assignment’ or ‘can I pay someone to do my assignment. Then Singapore Assignment help brings to you the finest solution that can solve all your academic writing problems.  we have a team of SUSS University assignment helpers who hold masters and Ph.D. degrees from the top universities. Our experts are committed to delivering the best solution on a computer science assignment. Our experts are familiar with the university guideline and always deliver all types of solutions within the deadline

Answer

Looking for Plagiarism free Answers for your college/ university Assignments.

Ask Your Homework Today!

We have over 1000 academic writers ready and waiting to help you achieve academic success