Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 747057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:09:42+00:00 2026-05-14T14:09:42+00:00

I have one class called Person that basically looks like: public class Person {

  • 0

I have one class called Person that basically looks like:

public class Person
{
    String firstName;
    String lastName;
    String telephone;
    String email;

    public Person()
    {
       firstName = "";
       lastName = "";
       telephone = "";
       email = "";
    }

    public Person(String firstName, String lastName, String telephone, String email) 
    {
        this.firstName = firstName;
        this.lastName = lastName;
        this.telephone = telephone;
        this.email = email;
    }

    public String getFirstName()
    {
        return firstName;
    }

    public void setFirstName(String firstName)
    {
        this.firstName = firstName;
    }
 ....

Using that class, I setup an abstract class called Loan that looks like:

public abstract class Loan
{   
    public void setClient(Person client)
    {
        this.client = client;
    }

    public Person getClient()
    {
        return client;
    }

    public void setLoanId(int nextId)
    {
        loanId = nextId;
        nextId++;
    }

    public int getLoanId()
    {
        return loanId;
    }

    public void setInterestRate(double interestRate)
    {
        this.interestRate = interestRate;
    }

    public double getInterestRate()
    {
        return interestRate;
    }

    public void setLoanLength(int loanLength)
    {
        this.loanLength = loanLength;
    }

    public int getLoanLength()
    {
        return loanLength;
    }

    public void setLoanAmount(double loanAmount)
    {
        this.loanAmount = loanAmount;
    }

    public double getLoanAmount(double loanAmount)
    {
        return loanAmount;
    }

    private Person client;
    private int loanId;
    private double interestRate;
    private int loanLength;
    private double loanAmount;
    private static int nextId = 1;

}

I have to extend the Loan class with CarLoan and it looks like:

public class CarLoan extends Loan
{
    public CarLoan(Person client, double vehiclePrice, double downPayment, double salesTax,
                    double interestRate, CAR_LOAN_TERMS length)
    {
        super.setClient(client);
        super.setInterestRate(interestRate);
        this.client = client;
        this.vehiclePrice = vehiclePrice;
        this.downPayment = downPayment;
        this.salesTax = salesTax;
        this.length = length;

    }

    public void setVehiclePrice(double vehiclePrice)
    {
        this.vehiclePrice = vehiclePrice;
    }

    public double getVehiclePrice()
    {
        return vehiclePrice;
    }

    public void setDownPayment(double downPayment)
    {
        this.downPayment = downPayment;
    }

    public double getDownPayment()
    {
        return downPayment;
    }

    public void setSalesTax(double salesTax)
    {
        this.salesTax = salesTax;
    }

    public double getSalesTax()
    {
        return salesTax;
    }

    public String toString()
    {
        return getClass().getName() + "[vehiclePrice = " + vehiclePrice + '\n' 
                                        + "downPayment = " + downPayment + '\n'
                                        + "salesTax = " + salesTax 
                                        + "]";
    }

    public enum CAR_LOAN_TERMS {TWO_YEAR, THREE_YEAR, SIX_YEAR};
    private double vehiclePrice;
    private double downPayment;
    private double salesTax;

Few questions.

(a) Is what I did in the Loan class to setClient correct given what I have in the Person class? (e.g.this.client = client)

(b) Can I call super twice in a method? I have to set two attributes from the Loan class from the constructor in the CarLoan class and I thought that would be a way to do it.

(c) Do you have to set attributes for enumeration types differently in a constructor or getter/setter methods? I get an error for (this.length = length) in my CarLoan class and I was unsure of how enumeration values should be set. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:09:43+00:00Added an answer on May 14, 2026 at 2:09 pm

    OK, in order:

    1. setClient Looks perfectly fine. Nothing wrong with it. However, you want to avoid setting this.client directly in the CarLoan constructor—you’re already calling setClient (thanks to @Gabriel and @Aeth).
    2. Sure, you can use super to access the parent class methods as much as you want. What you need to be careful with is calling the superclass’ constructor, which you can only do once and at the beginning of the subclass’ constructor. super != super().
    3. Nope, this.length = length is fine. The problem is that you don’t have a field called length. You might want to add one of those.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one class called Holder (holder.cs) that contain the following: string name; List<String>
I have a really simple class with two methods; One that will be called
I have an object that is generated in one class public class CreatingClass {
I have one class that needs to grab an attribute that is set in
Let's say I have one class Foo that has a bunch of logic in
I'm used to the Java model where you can have one public class per
I have a similar scenario as this one: public class TestLinq2Xml { private XElement
Morning. Issue: I have a class called Reports. Two constructors. One allows no parameters,
I have a class called Person, which contains various properties such as first name,
I used to have one class for one file. For example car.cs has the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.