Add 2 constructors to the Course class. One that takes no arguments and initializes the data to all 0’s and “” (empty strings). And one constructor that takes all 4 arguments, one argument for each property and then sets the properties to these arguments that are passed in. Lastly change the main to use these new Constructors. You will not need to call the set functions any more, but do not remove the set functions from your class. Main Code à Course c1; c1 = new Course(323, “Intro to Php”, “Intro to Php Programming”, 4); c1.display(); Problem #2: Do the same as above for the Account class. Problem #3: Do the same as above for the Person class. Below is my Course code public class Course { int Courzeld; String CourteName; String Description; int creditHours; void display() { System.out.println("Course ID: " + Courzeld); System.out.println("Course Name: " + CourteName); System.out.println("Description: " + Description); System.out.println("Credit Hours: " + creditHours); } public static void main(String[] args) { Course c1; c1 = new Course(); c1.CourteName = "Intro to Python"; c1.Description = "This course intros the Python Prog Lang."; c1.Courzeld = 109; c1.creditHours = 4; c1.display(); } } Here is my code for Account public class Account { private int AcctNo; private String Owner; private double balance; public Account(int AcctNo, String Owner, double balance) { this.AcctNo = AcctNo; this.Owner = Owner; this.balance = balance; } public int getAcctNo() { return AcctNo; } public void setAcctNo(int AcctNo) { this.AcctNo = AcctNo; } public String getOwner() { return Owner; } public void setOwner(String Owner) { this.Owner = Owner; } public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } public void display() { System.out.println("Account Number: " + AcctNo); System.out.println("Owner: " + Owner); System.out.println("Balance: $" + balance); } public static void main(String[] args) { Account myAccount = new Account(12345, "John Doe", 1000.0); myAccount.display(); } } And here is my code for Person class Person { public String firstName; public String lastName; public String address; public String email; public void display() { System.out.println("First Name: " + firstName); System.out.println("Last Name: " + lastName); System.out.println("Address: " + address); System.out.println("Email: " + email); } public static void main(String[] args) { Person person = new Person(); person.firstName = "John"; person.lastName = "Doe"; person.address = "123 Main Street, City, State, Zip"; person.email = "johndoe@example.com"; person.display(); } }
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Add 2 constructors to the Course class. One that takes no arguments and initializes the data to all 0’s and “” (empty strings). And one constructor that takes all 4 arguments, one argument for each property and then sets the properties to these arguments that are passed in. Lastly change the main to use these new Constructors. You will not need to call the set functions any more, but do not remove the set functions from your class.
Main Code à
Course c1;
c1 = new Course(323, “Intro to Php”, “Intro to Php
c1.display();
- Problem #2: Do the same as above for the Account class.
- Problem #3: Do the same as above for the Person class.
Below is my Course code
Step by step
Solved in 4 steps with 2 images