Create ProductMock Entity which throws DataEntryException when its properties initialize with following values. Get the Product details from the user and handle in-built and user defined exception. Refer the class diagram given below :
Condition | Exception Message
__________________________________________________________________________________
productID <=0 | Product ID must be greater than zero productName = = “” | Product Name cannot be left blank
price <=0 | Price of product must be greater than zero.
productName | Product Name should have alphabets and numbers only
Product Mock:
ProductId: int
ProductName: String
Price: Double
Output:
Enter Id: -32
Enter Product Name: Compaq Laptop
Enter Price: 32000
Product Id must be greater than 0
ABC Corp wants to maintain list of Customers. While accepting the data, you need to validate CreditLimit property. If the value is invalid, you need to raise Exception. We need to implement custom exception class to implement the same.
Task 1: Define a Customer class with following members CustomerId, Customer Name, Address, City, Phone, CreditLimit
Task 2: Define the properties for all these members.
Task 3: Define two constructors (Default and Parameterised) to assign the values.
Task 4: You need to validate the CreditLimit. If the value is above 50000, then you need to raise Exception to handle this. Create InvalidCreditLimit custom Exception class to achieve the same.
Task 5: Use the Exception class created to throw the exception. Ensure that the Client application catches the exception and handles the error properly.
There is a Change request from the customer. It is as follows: You need to calculate Interest paid by banks on Saving Account.
Task 1 : Add a function declaration “void CalculateInterest()” in the interface. Define the functions in the concrete classes such as ICICI accounts get 7% interest and HSBC gives 5% interest.
Create two classes named Mammals and SeaAnimal. Create another class named Whale which inherits both the above classes. Now, create a function in each of these classes which prints "I am mammal" in class Mammals, "I am a marine animal” in class SeaAnimal and "I belong to both the categories: Mammals as well as Marine Animals" in class Whale. Now, create an object for each of the above class in main function and try calling.
1 - function of Mammals by the object of Mammal
2 - function of SeaAnimal by the object of SeaAnimal
3 - function of Whale by the object of Whale
4 - function of each of its parent by the object of Whale
to develop an object-oriented application. They provide trucks, cars, and bikes on rent for a maximum period of 5 days, and if the number of days increases they double the rent for the extra days. They have different cars like luxury, sports and ordinary and all of them are powered by both electricity and petrol while trucks have only petrol option. In the case of bikes, they have electric street-bike and sportbikes have only petrol option. Further, the choice of the customer for the trucks is based upon weight, length, and wheels. The owner of the company can add, view and update vehicle, customer, and employee information.
Create a class: Doctor, with private data members: id, name, specialization and salary
with public member function: get_data () to take input for all data members, show_data
() to display the values of all data members and get specialization () to return
specialization. Write a program to write for detail of n doctors by allocating the
memory at run time only.
Write a Python program using text files to create a Smart Phone book that collects contact details from the user. Contact details refer to the contact’s full name (first name and last name), phone number, date of birth and a category that the contact belongs to (Friends, Family, Work, Other). The Phone Book will display the following Menu and will support the corresponding functionality:
Enter your choice: 1: Add a new contact 2: Remove an existing contact 3: Look up a contact 4: Update a contact phone number 5: Display all contacts 6: Delete all contacts 7: Exit phonebook
Based on Control Structure Selection and Control Structure Looping, answer the following questions:
Write a program that will ask the user to input n positive numbers. The program will terminate if one of those numbers is not positive. Output :
https://cdn.discordapp.com/attachments/711213157854609461/839150310864846934/unknown.png