Question
1) Constitute a Person class that meets the following conditions: Its attributes are: name, age, DNI, sex (M male, M female), weight and height. No,
1) Constitute a Person class that meets the following conditions:
Its attributes are: name, age, DNI, sex (M male, M female), weight and height. No, we want them to be accessed directly. Think which access modifier is the most suitable, also its type. If you want to add any attributes, you can. By default, all the attributes except the DNI will be default values according to their type (numbers 0, empty string for String, etc.). The gender will be male by default, use a constant for it. Several constructors will be implemented: a) A default constructor. b) A constructor with the name, age and sex, the rest by default. c) A constructor with all attributes as parameters. d) The methods to implement are: e) calculate BMI(): it will calculate if the person is at their ideal weight (weight in kg/(height^2 in m)), if this formula returns a value less than 20, the function returns -1, if it returns a number between 20 and 25 (included), it means that you have a perfect low-weight function. f) it returns a 0 and if it returns a value greater than 25 it means that it is overweight, the function returns a 1. I recommend that you use constants to return these values. g) esMayorDeEdad(): indicates if he is of legal age, returns a boolean. h) checkSex(char sex): verifies that the entered sex is correct. If it's not correct, it will be H. It will not be visible from the outside. i) toString(): returns all the information of the object. j) generateDNI(): generates a random 8-digit number, generates its corresponding letter from this number. This method will be called when the object is constructed. You can split the method to make it easier for you. It will not be visible from the outside. k) Establish methods of each parameter, except DNI. Create an executable class that does the following: Name, age, gender, weight and height must be entered by keyboard. l) Create 3 objects of the above class, the first object will get the above variables requested by keyboard, the second object will get all of the above except weight and height and the last one by default, for the latter it uses the set methods to give a value to attributes. m) For each object, you must check if you are at your ideal weight, overweight or underweight with a message. n) Indicate for each object if it is of legal age. o) Finally, show the information of each object. p) You can use methods in the executable class, to make it easier for you.
2) Create a Video Game class with the following characteristics: Its attributes are title, estimated hours, delivered, gender and company. By default, the estimated hours will be 10 hours and false will be delivered. The rest of the attributes They will be default values according to the type of attribute. The constructors to implement will be: a) A default constructor. b) A builder with title and estimated hours. The rest by default. c) A constructor with all attributes except delivered. The methods to implement are: d) Methods of obtaining all attributes except delivered. e) Set methods of all attributes except delivered. f) Override the toString methods. g) deliver(): change the rendered attribute to true.
h) return(): change the rendered attribute to false. i) isDelivered(): returns the status of the delivered attribute. j) compareTo method (Object a), compares the estimated hours in video games. Implement the above methods in the VideoGame classes. Now create a application executable and do the following: k) Create a matrix, for video games, with 5 positions each. l) Create an object at each position of the array, with whatever values you want, you can use different builders. m) Deliver a delivery of Video Games(). n) Count how many Video Games are delivered. As you count them, return them. o) Finally, indicate that the Video Game has more estimated hours. p) Show all the information on the screen (use the toString() method).
3)Create a class called Password that meets the following conditions: Have the length and password attributes. By default the length will be 8. The constructors will be the following: a) A default constructor. b) A constructor with the length that we pass to it. It will generate a password random with that length. The methods that will be implemented will be: c) isStrong(): returns a boolean if it is strong or not, to be strong it must have more 2 uppercase, more than 1 lowercase and more than 5 numbers. d) generatePassword(): generates the password of the object with the length it has. e) Get method for password and length. f) Set the method for length. g) Create a class executable and try: Create an array of Passwords with the size indicated by the keyboard. Create a loop that creates an object for each position in the array. It also indicates by keyboard the length of the Passwords (before the loop). Create another array of boolean values where
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started