Question

Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...

Can you please pick Automobile For this assignment. Java Programming

Second Inheritance OOP assignment Outcome: Student will demonstrate the ability to use inheritance in Java programs. Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following: Person Automobile Animal Based on your choice: If you choose Person, you will create a subclass of Person called Student. If you choose Automobile, you will create a subclass of Automobile called RaceCar. If you choose Animal, you will create a subclass of Animal called Horse. Once you pick your theme, you must use the “HAS A” question to determine the fields that you are going to include in your classes. For example, an Alarm Clock HAS A: Set Hours Button Time Set Minutes Button Time Set Hours Button Alarm Set Minutes Button Alarm Alarm On-Off Button Snooze Button Tasks: Create UMLs for all classes. WRITE JAVA code to create the classes from above. In the classes you are creating you will include at least three fields or attributes (See sample alarm clock above). Add overloaded methods, and overridden methods. Label each. Create a Test class that creates at least 3 objects of each class. The parent and child classes need to have all necessary and required methods. Test your work. Zip up the project folder (no design tool needed). .

YOU MAY NOT EVER:

Use global variables.

Use the word goto. Use the break command outside a case statement.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//########################## PGM START #############################################

class Person{
   int id;
   String name;
  
   //overloading
   Person(){
       this.name="X";
       this.id=-1;
   }
   Person(int idt,String name){
       this.id=idt;
       this.name=name;
   }
   //getters and setters
   public int getId() {
       return id;
   }
   public void setId(int id) {
       this.id = id;
   }
   public String getName() {
       return name;
   }
   public void setName(String name) {
       this.name = name;
   }
  
   public String toString() {
       return "\nPerson details.....\nName: "+this.name+"\nID No: "+this.id+"\n";
   }
  
}
class Student extends Person{
   String stream;
   String college;
   double anualFee;
   Student(int id,String name,String strm,String clg,double fee){
       super(id,name);
       this.stream=strm;
       this.college=clg;
       this.anualFee=fee;
   }
   public String getStream() {
       return stream;
   }
   public void setStream(String stream) {
       this.stream = stream;
   }
   public String getCollege() {
       return college;
   }
   public void setCollege(String college) {
       this.college = college;
   }
   public double getAnualFee() {
       return anualFee;
   }
   public void setAnualFee(double anualFee) {
       this.anualFee = anualFee;
   }
   //overriding toString method of Person
   public String toString() {
       return super.toString()+"Stream: "+this.stream+"\nCollege: "+this.college+"\nAnnual Fee: $"+this.anualFee+"\n";
   }
  
}
public class PersonTest {

   public static void main(String[] args) {
       //creating 3 objects for Person class
               Person p1=new Person(126789,"Mike");
               Person p2=new Person(156889,"John");
               Person p3=new Person(229089,"Trumph");
              
               //printing the values of Person class objects
               System.out.println("\t\tPerson Data\n----------------------------------------\n");
               System.out.println(p1);
               System.out.println(p2);
               System.out.println(p3);
              
               //creating 3 objects of Student class
               Student s1=new Student(667889,"Emi","Science","MIT",6000);
               Student s2=new Student(667988,"Mia","Maths","VIT",9000);
               Student s3=new Student(667752,"Zam","Commerce","CIT",5500);
              
               //printing the values of STudent class objects
               System.out.println("\t\tStudent Data\n----------------------------------------\n");
               System.out.println(s1);
               System.out.println(s2);
               System.out.println(s3);


   }

}

//########################## PGM END ############################################
OUTPUT
########

Add a comment
Know the answer?
Add Answer to:
Can you please pick Automobile For this assignment. Java Programming Second Inheritance OOP assignment Outcome: Student...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome: ...

    java. do it on eclipse. the same way its instructed Second Inheritance OOP assignment Outcome:  Student will demonstrate the ability to understand inheritance Program Specifications: Programming assignment: Classes and Inheritance You are to pick your own theme for a new Parent class. You can pick from one of the following:  Person  Automobile  Animal  If you choose Person, you will create a subclass of Person called Student.  If you choose Automobile, you will create a...

  • JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance...

    JAVA - Abstraction and Encapsulation are one pillar of OOP (Object Oriented Programming). Another is inheritance and polymorphism. In this assignment we will use inheritance and polymorphism to solve a problem. Part (a) of the figure below shows a symbolic representation of an electric circuit called an amplifier. The input to the amplifier is the voltage vi and the output is the voltage vo. The output of an amplifier is proportional to the input. The constant of proportionality is called...

  • Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • Please help me with the following question. This is for Java programming. In this assignment you...

    Please help me with the following question. This is for Java programming. In this assignment you are going to demonstrate the uses of inheritance and polymorphism. You will create an Animals class and a Zoo class that holds all the animals. You should create a general Animalclass where all other classes are derived from (except for the Zoo class). You should then create general classes such as Mammal, Reptile, and whatever else you choose based off of the Animalclass. For...

  • What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that...

    What is the code for this in Java? Assignment Inheritance Learning Objectives Declare a subclass that derives from a superclas:s ■ Demon "Declare a variable of the superclass type and assign it an instance of the subclass type strate polymorphic behavior Access the public members of the superclass type Notice how the overridden versions of the subclass type are called Notice how the subclass specific members are inaccessible "Create an array of superclass type and use a foreach loop to...

  • The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario...

    The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario is to design an online shopping system for a local supermarket (e.g., Europa Foods Supermarket or Wang Long Oriental Supermarket) and is mostly concentrated on the product registration system. Design and draw a UML diagram, and write the code for the following classes: ID: The identification number must start with 1 and follows with 6 numbers, e.g., “1123456”. Description, e.g. “Banana” Recommended Price per...

  • Write java program The purpose of this assignment is to practice OOP with Array and Arraylist,...

    Write java program The purpose of this assignment is to practice OOP with Array and Arraylist, Class design, Interfaces and Polymorphism. Create a NetBeans project named HW3_Yourld. Develop classes for the required solutions. Important: Apply good programming practices Use meaningful variable and constant names. Provide comment describing your program purpose and major steps of your solution. Show your name, university id and section number as a comment at the start of each class. Submit to Moodle a compressed folder of...

  •            1.         You often need to know the inheritance ____________________ of the Java API to work...

               1.         You often need to know the inheritance ____________________ of the Java API to work with its classes and subclasses.            2.         All objects have access to the methods of the ____________ class.            3.         If two classes share some common elements, you can define those elements in a ____________.            4.         To call a constructor or method of a superclass from a subclass, you use the ____________ keyword.            5.         A class that can be inherited by another...

  • In JAVA, please In this module, you will combine your knowledge of class objects, inheritance and...

    In JAVA, please In this module, you will combine your knowledge of class objects, inheritance and linked lists. You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: 1. description - which is a string 2. write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT