Saturday, March 30, 2019
Object oriented programming with subclasses
Object oriented programming with sub crime syndicateesInheritance Polymorphism addicted someone kinfolk definition below crime syndicate Person snobby String let outPerson(String name) this.name = name overt String getName() return nameDesign two sub categorisees of Person, named Student and Employee. Make Faculty and Staff sub var.es of Employee. An authority of Student has a class status (freshman, sophomore, junior, and senior). Declare the status as constants in the Student class. An instance of Employee has a department, salary, and date-hired. Define a class named MyDate that contains expanses of the year, month, and day. A faculty member has office hours and a say (lecturer, senior lecturer, associate professor, and professor). A staff member has a gear up title. Override the toString() mode inPerson class to screening the class name and the persons name.Student class to display class name, students name and class status.Employee class to display class name, employ ees name, and departmentFaculty class to display class name, employees name, office hours and rankStaff class to display class name, employees name, position titleDraw a class diagram to play the relationship of the classes above.Using Java to write and implement the classes with regard to the class diagram. print a test program in Java that creates instances of Person, Student, Employee, Faculty, and Staff, and invokes their toString() method. indite another test program in Java that creates instances of Person, Student, Employee, Faculty, and Staff in an array of Object. Use a repetition statement to c each its toString() method. neuter the classes in question (1) aboveAdd a package ctb2209.p7 to Person class, and then compile all the classes again. Explain the errors and fix it.Design a class named Square that contains data fields for height, width, and an lift method named computeSurfaceArea(). constrain a child class named Cube. Cube contains an additional data field named d epth, and overrides computeSurfaceArea() method inherited from its parent method.Implement all the classes.Write an finishing that instantiates rejects of Square and Cube in an array and displays the surface areas of each object using iteration, and test all the methods of all the objects. hit an abstract political machine class with fields for the car make and price. Include get and baffle methods for these fields the calculatePrice() method is abstract. Create two subclasses for individual automobile makers (for example, traverse or Honda), and include appropriate calculatePrice() method in each subclass (for example, RM110,000 or RM120,000 respectively). Finally, write an application that uses the AutoMobile class as reference figure and instantiate objects of its subclasses to display education about different cars. Save the files as AutoMobile.java, Ford.java, Honda.java and UseAutoMobile.java.Create an interface called Player. The interface has an abstract method called play() that displays a nub describing the meaning of play to the class. Create classes called Child, Musician, and Actor that implement Player interface. Create an application that demonstrates the use of the classes. Save the files as Player.java, Child.java, Actor.java, Musician.java, and UsePlayer.java.Sunway Construction Loan embodied makes contributes of up to RM100,000,000,000 for construction projects. There are two categories of Loans those to businesses and those to individual applicants.Write an application that tracks all new construction loans. The application must alike calculate the total amount owed at the due date (original loan amount + loan fee). The application should include the following classesLoanConstants A public interface class. LoanConstants includes constant values for short-term (one year), medium-term (three years), and long-term (five years) loans. It also contains constants for the club name and the maximum loan amount.Loan A public abstract c lass that implements the LoanConstants interface. A Loan includes a loan number, customer death name, amount of loan, cheer rate, and term. The constructor requires data for each of the fields that interest rate. Do not allow loan amounts over RM100,000,000,000. rend any loan term that is not one of the three delineate in the LoanConstants class to a short-term (one-year) loan. Create a toString() method that displays all the loan data.BusinessLoan A public class that extends Loan. The BusinessLoan constructor sets the interest rate to 1% over the current basic interest rate.PersonalLoan A public class that extends Loan. The PersonalLoan constructor sets the interest rate to 2% over the current basic interest rate.CreateLoans An application that creates an array of five Loans. active that user for the current basic interest rate. Then, in a loop, alert the user for a loan type and all relevant information for that loan. Store the created Loan objects in the array. When dat a entry is complete, display all the loans.Save the files as Loan.java, LoanConstants.java, BusinessLoan.java, PersonalLoan.java, and CreateLoans.java.Note java.util.Date and java.text.SimpleDateFormat may needed for your total amount owed at the due date calculation, you may look at the usage of format() and parse() methods of SimplateDateFormat class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment