Answered step by step
Verified Expert Solution
Question
1 Approved Answer
S THOG 20 Nent L P L x NMT + - 3 X POP KRC CCFP COP CCC- D C O File C:/Users/Hunmbre Downloads/CS212L:b1 Week
S THOG 20 Nent L P L x NMT + - 3 X POP KRC CCFP COP CCC- D C O File C:/Users/Hunmbre Downloads/CS212L:b1 Week 20:21.pdf F SU 2018 Program 1 Earlier we discussed a Computer class with a Notebook class as its only Subclass. However, there are many different kinds of computers. An organization may have servers, mainframes, desktop PCs, and notebooks. There are also personal data assistants and game computers. So it may be more appropriate to declare class Computer as an abstract class that has an actual subclass for each category of computer. It is required to: a) Write an abstract class Computer that defines all the methods shown earlier and declares an abstract method with the signature double cost Benefit () that returns the cost-benefit (type double) for each category of computer. b) Write a parte computer class as a sub class of Abstract Corriputer class. Make sure to implement any abstract methods and add any necessary data fields. c) Write a server class as a sub class of Abstract Computer class. Make sure to implement any abstract methods and add any necessary data fields. d) Test your code by creating a main method that creates a game computer object and server object and print all the information of cach one of them in addition to the computed cost-benefit. 1 10:43 AM - Type here to search Type here to search e 2:24/2020 CS 212 Lab 1 Spring 2018 Week 3 Program 2 Complete the code for the following class then write an equals method for the following class. What other equals methods should be defined? public class Airplane { // Data Fields Engine eng; Rudder rud; Wing[] wings = new Wing[2]; Test the added equals method by creating two objects from type Airplane and compare if they are equal or not. Try it on two different cases: when they parameters are equal and when the parameters are not equal. Program 3 Write class Fruit which is a cub class of the Food class discussed earlier. Assume that a fruit has three double constants: FRU_PROTEIN_CAL, FRU_FAT_CAL, and FRU_CARBO_CAL. Compute the fat percentage as FRU_FAT_CAL divided by the sum of all the constants. Test your code by creating a new Fruit object and print its FRU_FAT_CAL
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