Here is the diagram we made
Here is the Java code for the User Class
package com.spconger; public class User { private int userID; private String userName; public int getUserID() { return userID; } public void setUserID(int userID) { this.userID = userID; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } }
Here is the java code for the Customer class which inherits from User class
package com.spconger; public class Customer extends User { private String email; private String phoneNumber; private int rewardPoints; public int getRewardPoints() { return rewardPoints; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } public void addPoints(int points){ rewardPoints += points; } public void usingPoints(int points){ rewardPoints -= points; } }
Here is the C# code for the user class
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { abstract public class User { private int userID; private string userName; public int UserID { get => userID; set => userID = value; } public string UserName { get => userName; set => userName = value; } } }
Here is the C# code for the Customer class which inherits from User
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { public class Customer:User { public string Email { set; get; } public string PhoneNumber { set; get; } private int rewardPoints; public void AddPoints(int points) { rewardPoints += points; } public void UsingPoints(int points) { rewardPoints -= points; } public int GetRewardPoints() { return rewardPoints; } } }
No comments:
Post a Comment