Object Oriented Programming – Lab

Anonymous
timer Asked: Feb 1st, 2021

Question Description

hello, can you please solve me: Assign1: Q(1), Q(2), Q(5), Q(6) page 9 and 10

Assign2: Q(1) in page 10, As required in the questions. Thank you

Unformatted Attachment Preview

SWE 321 Object Oriented Programming – Lab Revision History Version 1.00 Semester Spring 2018 Author(s) Abdallah T., Andrew L., Eleana K., Emad B., and Sujith M. Reviewed by Zakaria M., and John G. 2.00 Fall 2018 Afshan P. Sujith M. 3.0 Spring 2020 Afshan P. Tarannum P. Sujith M. Comments Course is created to introduce CTI students to the basics of objectoriented design and programming with Python programming language. Updated exercises to emphasize basic concepts taught in SWE 225 and include Appendix section to introduce text file handling. Realigned and added exercises to match course delivery. Updated labs with new exercises. Also, changed the labs to suit the restructuring of SWE 320 and included exercises for chapter on GUI. Table of Contents 1 Introduction ........................................................................................................1 1.1 Grading Scheme ................................................................................................... 1 1.2 Submission Guidelines ......................................................................................... 1 1.2.1 Blackboard Portfolio ............................................................................................... 1 1.2.2 Submissions Deadlines ............................................................................................ 3 1.2.3 Code Documentation .............................................................................................. 4 1.2.4 Zayed University Honor Code................................................................................ 4 1.2.5 Plagiarism Policy ..................................................................................................... 4 2 Lab 1 – Review of Basic Programming Structures .........................................6 2.1 2.2 3 Lab 2 – UML Class Diagrams ..............................................................................9 3.1 3.2 4 Assignment 1 ...................................................................................................... 22 Lab 7 - Exception Handling ............................................................................ 25 8.1 9 Assignment 1 ...................................................................................................... 18 Assignment 2 ...................................................................................................... 18 Lab 6 – Polymorphism ..................................................................................... 22 7.1 8 Assignment 1 ...................................................................................................... 15 Assignment 2 ...................................................................................................... 17 Lab 5 – Class Association ................................................................................. 18 6.1 6.2 7 Assignment 1 ...................................................................................................... 12 Assignment 2 ...................................................................................................... 13 Lab 4 – Inheritance .......................................................................................... 15 5.1 5.2 6 Assignment 1 ........................................................................................................ 9 Assignment 2 ...................................................................................................... 10 Lab 3 – Introduction to Python Classes ......................................................... 12 4.1 4.2 5 Assignment 1 ........................................................................................................ 6 Assignment 2 ........................................................................................................ 7 Assignment 1 ...................................................................................................... 25 Lab 8 – Graphical User Interface (GUI) ......................................................... 28 9.1 Assignment 1 ...................................................................................................... 28 10 Appendix ........................................................................................................... 30 10.1 10.2 10.3 10.4 Text File Reading and Writing .......................................................................... 30 UML Tool ............................................................................................................. 31 Grading Rubric .................................................................................................... 32 Grading Key......................................................................................................... 34 SWE-321 OOP Lab 1 Introduction This lab manual guides the students to complete the weekly assignments of SWE-321 Object Oriented Programming (OOP) Lab course. These assignments provide practical experiences for the concepts and principles taught in SWE-320 OOP (co-requisite course). All assignments in this document should be completed in the sequence that it is presented in to ensure proper learning gradient. 1.1 Grading Scheme The completion and submission of all assignments in this lab manual contributes to 70% of the total course grade. The remaining 30% is for project component. The rubric to grade each assignment and the Grading Key are provided in the Appendix section of this document. The lab assignments are graded by the instructor and the feedback is provided to the student via Blackboard. The onus is on the student to ensure that their individual lab portfolio is updated on a timely basis with the working solutions of the assignments so that they are graded regularly. 1.2 Submission Guidelines The solutions to all the assignments in this lab manual is submitted to a Blackboard portfolio that is created under each student’s Blackboard profile. The portfolio should be organized in the same order of weekly assignments that is presented in this document. The due dates for submissions are defined by the course instructor. Delayed submission could lead to reduction of scores as indicated in the rubric. Ensure to provide code in Python, sufficient documentation, screenshots of output, and other content to help in the assessment of the work submitted. 1.2.1 Blackboard Portfolio To create a Blackboard portfolio, follow these steps (see figures below). 1. Login to Blackboard 2. Open Global Navigation Menu by clicking on your name on the top-right corner. 3. Select Tools and then click on Portfolios (Tools->Portfolios) 4. Click on Create Portfolio College of Technological Innovations (CTI) 1 SWE 321 – OOP Lab. 5. Under General Information a. Title: SWE 321 – OOP Lab b. Check the Available option c. Uncheck the Comments are Private option 6. Organize the portfolio as shown below. Follow the organization of this document’s Table on Contents to organize the portfolio pages. College of Technological Innovations (CTI) 2 SWE 321 – OOP Lab. 7. The portfolio is updated with the solutions to the required assignments. 8. Updating the portfolio DOES NOT MEAN SUBMISSION. Please ensure that your portfolio is submitted as advised by the instructor on a regular basis for assessment. The instructor will NOT SEE and CANNOT EVALUATE the portfolio unless it is submitted to the instructor. 1.2.2 Submissions Deadlines This is a suggestion for submission deadlines that the lab instructor can use. • Lab 1 at the end of Week 2 • Lab 5 at the end of Week 9 • Lab 2 at the end of Week 4 • Lab 6 at the end of Week 10 • Lab 3 at the end of Week 6 • Lab 7 at the end of Week 11 • Lab 4 at the end of Week 7 • Lab 8 at the end of Week 12 Evaluation is completed by instructor at the end of each submission deadline. Each submission is a cumulative update of the previous submission. The lab manual as a whole would be the final submission. A separate submission of the final project is for Weeks 13-15 which is not assessed as part of the weekly lab assignments. College of Technological Innovations (CTI) 3 SWE 321 – OOP Lab. 1.2.3 Code Documentation Python code that is submitted as solutions for the assignments must contain proper documentation. Suggested header documentations are provided for programs and functions. All programs and all functions must contain sufficient documentation to explain their intent and use. • Program Header Suggestion: • # Program/Class Name: # Author(s): # Date of Creation: Class doc_string is to be included for all class definitions. • Function Header Suggestion: # Function Description: # Parameters: # Return Type: 1.2.4 Zayed University Honor Code “In the Name of God Most Gracious Most Merciful” As a student of the University that carries the name of the beloved and revered father of the nation, the late Sheikh Zayed Bin Sultan Al Nahayan (may his soul rest in eternal peace), I pledge to: • Demonstrate the virtues of honesty, respect and fairness • Adhere to the highest standards of personal moral conduct • Refrain from any and all forms of academic dishonesty • Present a positive image of myself by acting with maturity and honor • Take responsibility for my actions and do my part to maintain a community of trust • Dedicate myself to the achievement of the University’s excellence I promise to honor Sheikh Zayed and to preserve his legacy by following the example set by the wise and beloved father of the United Arab Emirates 1.2.5 Plagiarism Policy Plagiarism is presenting someone else’s work or ideas as if it were one’s own. Examples of plagiarism include the following: College of Technological Innovations (CTI) 4 SWE 321 – OOP Lab. • Copying another person’s work either word for word or making some changes but keeping the structure, much of the language, and main ideas the same. Even if the work is not published, it should be treated as someone else’s work and not one’s own work. • Buying, borrowing, or otherwise obtaining and handing in a paper, project or course assignment as if it were one’s own. • Turning in someone else’s paper as if it were one’s own is strictly prohibited, even if the paper is enclosed in quotation marks. A large part of a paper cannot simply be quotations. • Allowing someone else to edit, rewrite or make substantial changes in one’s work and turning it in as if one had done it all, without acknowledging the other person’s contribution and without prior permission of the instructor. • Using someone else’s words or ideas without crediting that person. o If a student uses someone else’s words, he must identify them by putting quotation marks around them and citing the source. o If a student downloads a picture from the Internet, he must cite the source of the picture. o If a student paraphrase someone’s work, he must specify the source of the statement. o Every book, magazine, or internet site used in a paper must be identified in the bibliography. • At any time, if a student thinks he may have unknowingly plagiarized someone’s work, he should discuss it with his instructor before turning in the assignment. College of Technological Innovations (CTI) 5 SWE 321 – OOP Lab. 2 Lab 1 – Review of Basic Programming Structures The assignments for this week provide a review of the topics in SWE-225 Introduction to Programming and Problem Solving (pre-requisite course). The objective here, is to review basic programming constructs, like primitive data types, sequential logic, branching with selection, repetitions, the use of functions, and creating collection of data using lists. 2.1 Assignment 1 Write a Python program with the following 10 functions. Solution to the first program given as a sample. o All input values are to be taken from the user. o Ensure to check for possible error cases like mismatch of data type and input out of range, for every function. o Include test cases for the functions with different parameters to ensure all working conditions. 1. greatestOfFour (w, x, y, z) - Function to find the greatest of four numbers w, x, y, and z, and return it. (Answer to this is given as an example) # Function Name: greatestOfFour # Desc: Finds greatest of 4 numbers # Parameters: num1 - int, num2 - int, num3 - int, num4 - int # Return: int def greatestOfFour(num1, num2, num3, num4): if num1>num2 and num1>num3 and num1>num4: return num1 elif num2>num3 and num2 >num4: return num2 elif num3>num4: return num3 else: return num4 # Read Input print("Enter four numbers to check the greatest: ") num1 = input("1st num: ") num2 = input("2nd num: ") num3 = input("3rd num: ") num4 = input("4th num: ") # Call function for Process and Output print("Greatest of 4 numbers: ") print(greatestOfFour(int(num1), int(num2), int(num3), int(num4))) College of Technological Innovations (CTI) 6 SWE 321 – OOP Lab. Output: 2. reverseSentence(sentence) - Function that reverses a given sentence given by user. 3. listEven(n1, n2) – Function to return list of all the even numbers between two numbers. 4. calculateTotalSalary(month_sal, no_of_years) - Function computes the total salary based on monthly salary and number of years. If the number of years is greater than 5 years, an increment of 5% is added to the total salary from 6th year. 5. listMax(numList) – Function to find the maximum from a list of numbers. 6. degreeToFahrenheit(degree_celcius) - Function that asks the user to input data in Degree Celsius (C) and convert it to Fahrenheit (F) using the formula, F= (C*5/9) +32. 7. countVowels(sentence) – Function that returns the count of vowels in a sentence. Check for both upper-case and lower-case alphabets. 8. factorial(num) - Function that computes the factorial of a number entered. Example: factorial of 5= 5*4*3*2*1. 9. commonData(list1, list2) - Function that takes two lists and returns true if they have at least one common element. 10. sortList(nList, order) – Function that sorts a list nList, either in descending or ascending order. 2.2 Assignment 2 1. Write a Python program that reads a text file called “sample.txt”. A sample of the file is provided below, you may add more details to the file. Your program must read the data from the file and count the number of words in the file sample.txt: I like Python Programming College of Technological Innovations (CTI) 7 SWE 321 – OOP Lab. 2. Write a Python program that reads a text file called bill.txt. The text file contains, itemIDs and item-prices. Your program should read each item and respective prices from the file; find the most expensive, least expensive item, count the number of items and give the total of all the prices. The program should output the report into a file called output.txt. A sample of source file and report file is given below. bill.txt: Item Price A01 50.00 B31 149.50 A41 179.00 F01 169.50 C45 185.75 H21 29.25 output.txt: ******************************************* BILL REPORT ******************************************* There are total of 6 items purchased. The most expensive item is “C45” with price 185.75 The least expensive item is “H21” with price 29.25 The total is 763.00 ****************************************** 3. Write a Python program asks the user to provide a username and password as shown below: Login: Username: John Password: abc@123 The Python program should check if the user exists in a text file named user.txt. If the user exists, it should welcome the user by printing “Welcome ”, if the user does not exist, it should print “Invalid User”. The sample text file is given below: user.txt: John abc@123 Tom pqr@789 Mary xyz@456 College of Technological Innovations (CTI) 8 SWE 321 – OOP Lab. 3 Lab 2 – UML Class Diagrams The assignments for this week reviews Object Oriented design with UML notations to describe classes, attributes/data, behavior/functions, and class relationships like Association, Aggregation, Composition, and Inheritance. See Appendix A to download a tool to draw UML class diagrams. 3.1 Assignment 1 1. Design and draw a UML class diagram with attributes and behaviors to represent a customer of an online shopping web site. The student can make their own decision on the attribute and behaviors but ensure to select at-least 5 attributes and related behaviors. 2. Design and draw a UML class diagram with attributes and behavior to represent the features of a mobile phone. The student can make their own decision on the attribute and behaviors but ensure to select at-least 5 attributes and related behaviors. 3. Design and draw a UML class diagram to model different kinds-of vehicles such as bicycles, motorbikes, and cars. All vehicles have some common attributes like model number, color, year of manufacture, number of wheels, etc. The students must add additional attributes and methods as they see fit. 4. Design and draw UML class diagram to represent an airline reservation system. The system enables the customer to search for airline flight on a specified date and choose a flight based on some details like availability. The customer can reserve a flight or cancel his reservation. The system displays all the flight details such as flight number, name, price and duration of journey. 5. Draw a UML class diagram showing representing different types of payment transactions that a customer can make at a store. A payment can be done through cash, credit card, cheque, or wire transfer. The students can add attributes and methods as they see fit. College of Technological Innovations (CTI) 9 SWE 321 – OOP Lab. 6. For UML class diagram given below (Figure 1), identify the classes and their relationships and multiplicity. Based on your understanding of the class diagram in Figure 1, write a paragraph explaining all classes and their relationships. Figure 1- Class Diagram 3.1 3.2 Assignment 2 1. Design and draw UML class diagram with attributes, behavior, and class relationships for the following scenario. In a university there are different departments. A department has a name and is associated to classrooms and offices. An employee working at the university has a unique ID and can be a professor or an instructor. A professor can be a full professor, associate professor or assistant professor and she/he belongs to a department in the university. Offices and classrooms also have a unique IDs and classrooms have a fixed number of seats. Also, every employee is assigned an office. 2. Design and draw UML class diagram with attributes, behavior, and class relationships for the following scenario. MARVEL Videos is a chain of 11 video stores scattered throughout a major metropolitan area in the Midwest. The chain started with a single store several years ago and has grown to its present size. Paul Luis, the owner of the chain, knows that to compete with the national chains will require a state-of-the-art movie rental system. You have been asked to develop the system requirements for the new system. College of Technological Innovations (CTI) 10 SWE 321 – OOP Lab. Each store has a stock of movies and video games for rent. It is important to keep track of each movie title to know and to identify its category (classical, drama, comedy, and so on), its rental type (new release, standard), movie rating, and other general information such as movie producer, release date, cost, and so forth. In addition to tracking each title, the business must track each individual copy to note its purchase date, its condition, and its rental status. User functions must be provided to maintain this inventory information. Customers are also tracked. MARVEL considers each family to be a customer, so special mailings and promotions are offered to each household. For any ...
Student has agreed that all tutoring, explanations, and answers provided by the tutor will be used to help in the learning process and in accordance with Studypool's honor code & terms of service.

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors