Smaller task & refactoring co2
This commit is contained in:
		
							parent
							
								
									e45d52037f
								
							
						
					
					
						commit
						1464df11cf
					
				
					 29 changed files with 683 additions and 0 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/repetition-classes-oop/src/App.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/repetition-classes-oop/src/App.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										28
									
								
								Code/Steiner/repetition-classes-oop/src/App.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Code/Steiner/repetition-classes-oop/src/App.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| 
 | ||||
| // Main application class where we create a Teacher object and display some | ||||
| // info. | ||||
| public class App { | ||||
|     public static void main(String[] args) throws Exception { | ||||
|         // Sample data for creating a Teacher object. | ||||
|         String firstname = "Karl"; | ||||
|         String lastname = "Marx"; | ||||
|         int compensation = 1000000; | ||||
|         String[] subjects = { "Economics", "Math", "German" }; | ||||
| 
 | ||||
|         // Creating a Teacher object using the data above. | ||||
|         Teacher teacher = new Teacher(firstname, lastname, compensation, subjects); | ||||
| 
 | ||||
|         // Printing the teacher's full name. | ||||
|         System.out.println("Teacher: " + teacher.getFirstname() + " " + teacher.getLastname()); | ||||
| 
 | ||||
|         // Printing the teacher's compensation. | ||||
|         System.out.println("Compensation: " + teacher.getCompensation()); | ||||
| 
 | ||||
|         // Printing the subjects the teacher teaches. | ||||
|         System.out.print("Subjects: "); | ||||
|         // Loop through each subject in the array and print it. | ||||
|         for (String subject : teacher.getSubjects()) { | ||||
|             System.out.print(subject + " "); | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								Code/Steiner/repetition-classes-oop/src/Teacher.class
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Code/Steiner/repetition-classes-oop/src/Teacher.class
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										61
									
								
								Code/Steiner/repetition-classes-oop/src/Teacher.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								Code/Steiner/repetition-classes-oop/src/Teacher.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,61 @@ | |||
| // The Teacher class represents a teacher with a first name, last name, compensation, and subjects they teach. | ||||
| public class Teacher { | ||||
|     // Private fields to store the teacher's first name, last name, compensation, | ||||
|     // and subjects. | ||||
|     private String firstname; | ||||
|     private String lastname; | ||||
|     private int compensation; | ||||
|     private String[] subjects; | ||||
| 
 | ||||
|     // Constructor for initializing a Teacher object with provided details. | ||||
|     public Teacher(String firstname, String lastname, int compensation, String[] subjects) { | ||||
|         // Assigning the provided first name to the teacher's firstname field. | ||||
|         this.firstname = firstname; | ||||
|         // Assigning the provided last name to the teacher's lastname field. | ||||
|         this.lastname = lastname; | ||||
|         // Assigning the provided compensation to the teacher's compensation field. | ||||
|         this.compensation = compensation; | ||||
|         // Assigning the provided array of subjects to the teacher's subjects field. | ||||
|         this.subjects = subjects; | ||||
|     } | ||||
| 
 | ||||
|     // Getter method for getting the teacher's first name. | ||||
|     public String getFirstname() { | ||||
|         return firstname; | ||||
|     } | ||||
| 
 | ||||
|     // Setter method for setting a new first name for the teacher. | ||||
|     public void setFirstname(String firstname) { | ||||
|         this.firstname = firstname; | ||||
|     } | ||||
| 
 | ||||
|     // Getter method for getting the teacher's last name. | ||||
|     public String getLastname() { | ||||
|         return lastname; | ||||
|     } | ||||
| 
 | ||||
|     // Setter method for setting a new last name for the teacher. | ||||
|     public void setLastname(String lastname) { | ||||
|         this.lastname = lastname; | ||||
|     } | ||||
| 
 | ||||
|     // Getter method for getting the teacher's compensation. | ||||
|     public int getCompensation() { | ||||
|         return compensation; | ||||
|     } | ||||
| 
 | ||||
|     // Setter method for setting a new compensation for the teacher. | ||||
|     public void setCompensation(int compensation) { | ||||
|         this.compensation = compensation; | ||||
|     } | ||||
| 
 | ||||
|     // Getter method for getting the array of subjects the teacher teaches. | ||||
|     public String[] getSubjects() { | ||||
|         return subjects; | ||||
|     } | ||||
| 
 | ||||
|     // Setter method for setting a new array of subjects for the teacher. | ||||
|     public void setSubjects(String[] subjects) { | ||||
|         this.subjects = subjects; | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sage The DM
						Sage The DM