Giter VIP home page Giter VIP logo

object-oriented-programming-java-project's Introduction

Class Creation and Inheritance - Object Oriented Programming Java Project

Project for the Java Course of the Department of Programmers-Analysts of the School of Computer Programmers of the Hellenic Armed Forces

Description

Create a class named Person that has the following properties encapsulated:

  • idNumber
  • firstName
  • lastName
  • address
  • mobile

Create a constructor that accepts only the first 3 properties. Also, have for all properties the corresponding getters and setters and in addition the following methods:

  • getName where it returns the first and last name of Person together separated by a space
  • toString which displays the Person's data as follows:
Person {
ID Number: ...
First Name: ...
Last Name: ....
Address: ....
Mobile: ...
}

Then create a subclass named Student that has the following properties encapsulated:

  • program
  • entryYear
  • currentYear

The variable entryYear should only take integer values between the years 2000 and 2050. The variable currentYear shall only take values between 1 and 6.

Build a constructor that accepts only the first 3 properties of Person and the first 3 properties of Student. Have also for all properties, the corresponding getters and setters and in addition the following methods:

  • getStatus where it returns the student's name, program, entryYear, and currentYear
  • toString which displays all the Student's details using also the toString of Person

Then create a subclass named Staff that has the following properties encapsulated:

  • school
  • salary

The variable salary should only take floating-point values between 0 and 10000.

Build a constructor which accepts only the first 3 properties of Person and the first 2 properties of Staff. It should also have for all properties, the corresponding getters and setters and in addition the following methods:

  • toString which displays all elements of Staff using both toString of Person

Finally, build a program (main) in which the classes Student and Staff are used. That is, create two objects, a Student and a Staff and call the toString() methods for each object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.