Programming Java

Tasks studies - laboratory


Project maintained by dawidolko Hosted on GitHub Pages — Theme by dawidolko

Lab04 - Creating Classes and Objects in Java

Task 1.

Create a project named DaneOsobowe containing two classes: DaneOsobowe and Osoba (see the diagram below).


cmd_gcc

Complete the classes with the following code:
Osoba:


cmd_gcc

DaneOsobowe:


cmd_gcc

What results will be displayed in the console?

Important (Read This!!!):

Task 2.

Based on Task 1, create an application containing a class Student with the following fields: name, surname, student_id, specialization, year_of_study. Choose appropriate data types for the fields. Create four overloaded constructors for this class (each version of the constructor should accept at least one parameter—do not create an empty constructor). Create a method to display the student’s information. Create four objects of the Student class, each using a different constructor overload during object creation. For each object, run the method that displays the student’s information.

Task 3.

Create an application that allows entering student data from the console. Use the Scanner object and the Student class from Task 2 for this purpose.

Task 4.

Create a project ObliczanieFigur (Calculating Figures). Add classes to the project describing the following geometric shapes: Circle, Square, Rectangle, Cube, Cuboid, Sphere, Cone. For each class, choose appropriate fields. Also, create methods to calculate the areas, perimeters (for 2D shapes), and volumes (for 3D shapes). For each class, create a method to display information about the shape, such as its name, parameters, area, and perimeter or volume. Create objects for these shapes and show the calculation results using the display method.

Create a calculator for geometric shapes with a menu allowing: selecting a geometric shape and entering parameters for that shape from the console. Then display the results using the data display method.

Task 5.

Create a project named WprowadzDane (EnterData) containing a 100-element array of the Student class (use the Student class from Task 2). Create a method that creates an object for each array element and sets default values for it, such as 0 for numeric types and an empty string "" for string types.

Create methods enabling:

Optional (non-mandatory) tasks or elements of tasks.