design patterns – Should there only ever be one instance of a ViewModel object?

Assume a rather simplistic model:

class Person{   
   static List<Person> LivingPersons

   String Name
   List<Person> Dependents 
}

From this it can (hopefully) be seen that a single Person object can be both within the LivingPersons list and within the Dependents list of another Person object. Similarly, if there were a couple of ViewModels to represent this model:

class ViewModel_LivingPersons{
   static List<ViewModel_Person> LivingPersons
}

class ViewModel_Person{
   String Name
   List<ViewModel_Person> Dependents   
}

If I had a single Person object that resided in both the LivingPersons list and within the Dependents list of another Person, my gut feeling tells me that as it is the same model object being represented there should only ever be one instance of a ViewModel_Person to represent this model object. However, I do not know why, nor if this is best practice.

I’m not certain of the best practices here. I’ve done a bit of searching, but cannot find anything on this particular issue.

c# – Object orianted programing in a game

Right now I have a snake game that is working but I need a way to make my code look better and work better.

A method I named “GameSense” is very long and I need a way to make it more object oriented. I want to use Enums.

This is what my teacher sent back to me:

The game is very nice and nicely working tail! The test you have also follows the right idea but uses an UpdatePosition method that you have not implemented. I’m also thinking about your class pixel – you do not use it for anything in the rest of the game. You should use it instead of e.g. berryx, berryy. What I am trying to access is more use of object orientation and division into methods, and not a single long method like GameSense right now. Also want to see you use enum / bool instead of strings for e.g. the variables movement and buttonpressed. However, I’m glad you got an interface on a corner

As you can see… I feel pretty suck right now.
What do I need to do here in order to make the program be more object oriented?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Snake
{
    /// <summary>
    /// Start class, everything goes from here.
    /// Made by Karwan!
    /// </summary>
   public class Starter : InterF
    { 
        public static object Key { get; private set; }

        /// <summary>
        /// Main method.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string() args)
        {
            //Making the text green and also given a player 
            //options to chose from. 
            Console.ForegroundColor = ConsoleColor.Green;
            bool loopC = true;
            while (loopC)
            {
                string mystring = null; Console.WriteLine("Welcome to Snake.nPress S+Enter to start or press Q+Enter to exit.");
                mystring = Console.ReadLine();
                switch (mystring)
                {
                    case "Q":
                        Environment.Exit(0);
                        break;
                    case "S":
                        Console.WriteLine("Starting game!");
                        System.Threading.Thread.Sleep(4000);
                        loopC = false;
                        break;
                    default:
                        Console.WriteLine("Invalid Entry.. Try again.");
                        break;
                }

            }

            //Call for GameSense if
            //they want to play.
            GameSense(); 

        }


      
        /// <summary>
        /// Game object!
        /// </summary>
        public static void GameSense()

        {
            //Game console height/width.
            Console.WindowHeight = 30;
            Console.WindowWidth = 70;
            int screenwidth = Console.WindowWidth;
            int screenheight = Console.WindowHeight;
            Random randomnummer = new Random();
            //Lenght of tail == current score.
            int score = 2;
            int gameover = 0;
            //Gather positions from pixel class.
            pixel positions = new pixel();
            positions.xpos = screenwidth / 2;
            positions.ypos = screenheight / 2;
            positions.Black = ConsoleColor.Red;
            string movement = "RIGHT";
            //Position manegment.
            List<int> xpos = new List<int>();
            List<int> ypos = new List<int>();
            int berryx = randomnummer.Next(0, screenwidth);
            int berryy = randomnummer.Next(0, screenheight);
            //Time manegment.
            DateTime time1 = DateTime.Now;
            DateTime time2 = DateTime.Now;
            string buttonpressed = "no";

            
            //Draw world from GameWorld.cs.
            GameWorld.DrawBorder(screenwidth, screenheight);

            while (true)
            {
                GameWorld.ClearConsole(screenwidth, screenheight);
                if (positions.xpos == screenwidth - 1 || positions.xpos == 0 || positions.ypos == screenheight - 1 || positions.ypos == 0)
                {
                    gameover = 1;
                }

                Console.ForegroundColor = ConsoleColor.Green;
                if (berryx == positions.xpos && berryy == positions.ypos)
                {
                    score++;
                    berryx = randomnummer.Next(1, screenwidth - 2);
                    berryy = randomnummer.Next(1, screenheight - 2);
                }
                for (int i = 0; i < xpos.Count(); i++)
                {
                    Console.SetCursorPosition(xpos(i), ypos(i));
                    Console.Write("*");
                    if (xpos(i) == positions.xpos && ypos(i) == positions.ypos)
                    {
                        gameover = 1;
                    }
                }
                if (gameover == 1)
                {
                    break;
                }
                Console.SetCursorPosition(positions.xpos, positions.ypos);
                Console.ForegroundColor = positions.Black;
                Console.Write("*");
                //Food color & position.
                Console.SetCursorPosition(berryx, berryy);
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.Write("*");
                Console.CursorVisible = false;
                time1 = DateTime.Now;
                buttonpressed = "no";
                while (true)
                {
                    time2 = DateTime.Now;
                    if (time2.Subtract(time1).TotalMilliseconds > 500) { break; }
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo info = Console.ReadKey(true);
                        //Connecting the buttons to the x/y movments. 
                        if (info.Key.Equals(ConsoleKey.UpArrow) && movement != "DOWN" && buttonpressed == "no")
                        {
                            movement = "UP";
                            buttonpressed = "yes";
                        }
                        if (info.Key.Equals(ConsoleKey.DownArrow) && movement != "UP" && buttonpressed == "no")
                        {
                            movement = "DOWN";
                            buttonpressed = "yes";
                        }
                        if (info.Key.Equals(ConsoleKey.LeftArrow) && movement != "RIGHT" && buttonpressed == "no")
                        {
                            movement = "LEFT";
                            buttonpressed = "yes";
                        }
                        if (info.Key.Equals(ConsoleKey.RightArrow) && movement != "LEFT" && buttonpressed == "no")
                        {
                            movement = "RIGHT";
                            buttonpressed = "yes";
                        }
                    }
                }
                //Giving the connections value
                //to change x/y to make the movment happen.
                xpos.Add(positions.xpos);
                ypos.Add(positions.ypos);
                switch (movement)
                {
                    case "UP":
                        positions.ypos--;
                        break;
                    case "DOWN":
                        positions.ypos++;
                        break;
                    case "LEFT":
                        positions.xpos--;
                        break;
                    case "RIGHT":
                        positions.xpos++;
                        break;
                }
                if (xpos.Count() > score)
                {
                    xpos.RemoveAt(0);
                    ypos.RemoveAt(0);
                }
            }
            Console.SetCursorPosition(screenwidth / 5, screenheight / 2);
            Console.WriteLine("Game over, Score: " + score);
            Console.SetCursorPosition(screenwidth / 5, screenheight / 2 + 1);
            System.Threading.Thread.Sleep(1000);
            restart();
            
        }

        /// <summary>
        /// Restarter.
        /// </summary>
        public static void restart()
        {
        
            string Over = null; Console.WriteLine("nWould you like to start over? Y/N");
            bool O = true;

            while (O)
            {
                Over = Console.ReadLine();
                switch (Over)
                {
                    case "Y":
                        Console.WriteLine("nRestarting!");
                        System.Threading.Thread.Sleep(2000);
                        break;
                    case "N":
                        Console.WriteLine("nThank you for playing!");
                        Environment.Exit(0);
                        break;
                    default:
                        Console.WriteLine("Invalid Entry.. Try again.");
                        break;
                }
            }

        }
        /// <summary>
        /// Set/get pixel position.
        /// </summary>
       public class pixel
        {
            public int xpos { get; set; }
            public int ypos { get; set; }
            public ConsoleColor Black { get; set; }
        }
    }
}

My test class

using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Snake;
using System;
using System.Collections.Generic;
using System.Text;
using static Snake.Starter;

namespace Snake.Tests
{
    (TestClass())
    public class StarterTests
    {
        /// <summary>
        /// Testing the movment.
        /// </summary>
        (TestMethod())
        public void test()
        {
           
           var pos = new pixel();
            pos.xpos = 10;
            pos.ypos = 10;

            // this is the operation:
            UpdatePosition(pos, "UP");

            // check the results
            NUnit.Framework.Assert.That(pos.xpos, Is.EqualTo(10));
            NUnit.Framework.Assert.That(pos.ypos, Is.EqualTo(9));
        }

        /// <summary>
        /// Updating pixel class.
        /// </summary>
        /// <param name="pos"></param>
        /// <param name="v"></param>
        private void UpdatePosition(pixel pos, string v)
        {
            throw new NotImplementedException();
        }
    }
}

This is just the gameworld:

using System;
using System.Linq;

public class GameWorld 
{


    /// <summary>
    /// Clear console for snake.
    /// </summary>
    /// <param name="screenwidth"></param>
    /// <param name="screenheight"></param>
    public static void ClearConsole(int screenwidth, int screenheight)
    {
        var blackLine = string.Join("", new byte(screenwidth - 2).Select(b => " ").ToArray());
        Console.ForegroundColor = ConsoleColor.Black;
        for (int i = 1; i < screenheight - 1; i++)
        {
            Console.SetCursorPosition(1, i);
            Console.Write(blackLine);
        }
    }

    /// <summary>
    /// Draw boared.
    /// </summary>
    /// <param name="screenwidth"></param>
    /// <param name="screenheight"></param>
    public static void DrawBorder(int screenwidth, int screenheight)
    {
        var horizontalBar = string.Join("", new byte(screenwidth).Select(b => "■").ToArray());

        Console.SetCursorPosition(0, 0);
        Console.Write(horizontalBar);
        Console.SetCursorPosition(0, screenheight - 1);
        Console.Write(horizontalBar);

        for (int i = 0; i < screenheight; i++)
        {
            Console.SetCursorPosition(0, i);
            Console.Write("■");
            Console.SetCursorPosition(screenwidth - 1, i);
            Console.Write("■");
        }
    }

}

list manipulation – Part Specification is longer than depth of object & Transposing Errors

In trying to recreate results from another question I had asked (here)

Code is:

dataHist7 = {{16.5, 77.8}, {34.5, 63.5}, {54.5, 63.8}, {106.5, 42.4}, {124.5, 41.7}, {142.5, 14.6}, {160.5, 33.9}, {178.5, 29.4}, {196.5, 33.5}, {214.5, 30.9}, {232.5, 31.1}, {250.5, 21.5}, {268.5, 4.3}, {286.5, 6.4}, {322.5, 7.5}, {340.5, 4.5}, {358.5 , 11.0}, {376.5, 14.0}, {394.5, 14.0}, {466.5, 0.6}, {484.5, 2.2}, {520.5, 9.4}, {538.5, 4.1}, {646.5, 2.2}, {682.5, 0.6}}

data = Transpose({dataHist7((All, 1, 1)), dataHist7((All, 2, 1))});
ListLogPlot(data)

Which returns the errors:

Part::partd: Part specification {{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}((All,1,1)) is longer than depth of object.
Part::partd: Part specification {{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}((All,2,1)) is longer than depth of object.

Transpose::nmtx: The first two levels of {{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}((All,1,1)),{{16.5,77.8},{34.5,63.5},<<21>>,{646.5,2.2},{682.5,0.6}}((All,2,1))} cannot be transposed.

ListLogPlot::lpn: Transpose({{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}((All,1,1)),<<1>>}) is not a list of numbers or pairs of numbers.

ListLogPlot::lpn: Transpose({{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}((All,1,1)),<<1>>}) is not a list of numbers or pairs of numbers.

I assume the later errors are caused by the partd error. The error sheet suggests that there’s too few indices available for the transpose, but I don’t really understand how as it’s just a list of pairs? I’d like to know why this happens and how to remedy it?
Thanks

collision detection – How can I make player object collide and keep moving until it is as close as possible to click location?

I am making a basic point and click adventure game. I can make the player object move towards the location of a mouse click and collide with walls, but movement stops the instant a collision occurs. I would like the player object to keep moving (slide along the wall) and get as close as it can to the mouse click location, without passing through a wall of course. I have Create, Step, Collision & Global Mouse click events. Please see below for code and diagrams.

Any help will be much appreciated.

The player object (green square) should move towards the mouse click location, collide on the X axis, then slide down the Y axis before stopping in the corner of the walls

This is my player object. It is set to solid and uses a collide event to collide with the walls

Create Event code:

//stop player moving on create
enum mouse {
    none    
}
xx = mouse.none;
yy = mouse.none;
player_move_speed = 2;

//init
collision_speed = player_move_speed + 1;

Step Event code:

//general keys
if keyboard_check_pressed(vk_escape) {game_end()}


//point and click movement
if (xx != mouse.none and yy != mouse.none) {
    move_towards_point(xx,yy,player_move_speed);
} else {
    speed = 0;  
}

if (distance_to_point(xx,yy) < collision_speed) {
    xx = mouse.none;
    yy = mouse.none;
}

Global Left Pressed code:

xx = mouse_x;
yy = mouse_y;

software – How to return an new Object as Value ?[Sequence Diagram]

within the sequence diagram it is possible to return a value, with return of a method edge, however this is usually done with a simple numeric or string value. Is it possible to return a whole object? For example, I have the task to create a coffee and put 3 sugars in it.

Classes: initiator-Customer, Coffee and Sugar.

Two scenarios for completion:

First

  1. Customer calls new Coffee() which, generates a new coffee object
  2. From coffe object, call the add sugar from Sugar class, three times(loop) with addSugar(this).
  3. Return coffee object with 3 sugars to the Customer

Second

  1. Customer calls new Coffee() which, generates a new coffee object
  2. Return coffee object to customer class.
  3. Call three times(loop) from customer the Sugar class with coffee object as parmeter.

Which one is better ?

Unity Mirror client scene.local player.connection to client.client owned object not working in client

U hmm I’m new to mirror networking I just wanna find objects that the local player has authority, but it doesn’t work on client, is there a solution to this? Well I could make an object tracking script but that will complicate things.
This question might look like I haven’t research anything, truth is I’ve searched everywhere there is just no documentation for this

object oriented – A Tiny Image Tagger Implementation in C#

I am trying to implement a tiny image tagger with customized tag options in C#. The main window is as follows.

MainUIFigure

The left block is a picture box MainPictureBox and there are two buttons, PreviousButton and NextButton. Furthermore, there are some tags in a group box AttributeGroupBox. A save button SaveButton is used for saving tagged information.

The implemented functions:

  • Load images automatically in the folder which the program located.

  • Each image could be tagged.

  • The tag information of each image could be saved as a text file LabelResult.txt.

The experimental implementation

class Attribute
{
    public enum AttributeEnum
    {
        Mountain,
        Cat
    }

    public AttributeEnum attributeEnum;

    public override string ToString()
    {
        if (this.attributeEnum.Equals(AttributeEnum.Cat))
        {
            return "Cat";
        }
        if (this.attributeEnum.Equals(AttributeEnum.Mountain))
        {
            return "Mountain";
        }
        return "";
    }
}
public partial class Form1 : Form
{
    List<string> ImagePaths;
    List<Attribute> AttributeList;
    int index = 0;
    string targetDirectory = "./";
    public Form1()
    {
        InitializeComponent();

        
        System.IO.FileSystemWatcher watcher = new FileSystemWatcher()
        {
            Path = targetDirectory,
            Filter = "*.jpg | *.jpeg| *.bmp | *.png"
        };
        // Add event handlers for all events you want to handle
        watcher.Created += new FileSystemEventHandler(OnChanged);
        // Activate the watcher
        watcher.EnableRaisingEvents = true;

        ImagePaths = new List<string>();
        
        string() fileEntries = System.IO.Directory.GetFiles(targetDirectory);
        foreach (string fileName in fileEntries)
        {
            string filenameExt = System.IO.Path.GetExtension(fileName);
            if (filenameExt.Equals(".jpg") ||
                filenameExt.Equals(".jpeg") ||
                filenameExt.Equals(".bmp") ||
                filenameExt.Equals(".png")
                )
            {
                ImagePaths.Add(fileName);
            }
        }
        MainPictureBox.SizeMode = PictureBoxSizeMode.Zoom;
        MainPictureBox.Image = Image.FromFile(ImagePaths(0));

        AttributeList = new List<Attribute>();
        
    }

    private void OnChanged(object source, FileSystemEventArgs e)
    {
        ImagePaths.Clear();
        string() fileEntries = System.IO.Directory.GetFiles(targetDirectory);
        foreach (string fileName in fileEntries)
        {
            string filenameExt = System.IO.Path.GetExtension(fileName);
            if (filenameExt.Equals(".jpg") ||
                filenameExt.Equals(".jpeg") ||
                filenameExt.Equals(".bmp") ||
                filenameExt.Equals(".png")
                )
            {
                ImagePaths.Add(fileName);
            }
        }
    }

    private void PreviousButton_Click(object sender, EventArgs e)
    {
        index--;
        if (index <= 0)
        {
            index = 0;
        }
        MainPictureBox.Image = Image.FromFile(ImagePaths(index));
        GC.Collect();
    }

    private void NextButton_Click(object sender, EventArgs e)
    {
        NextAction();
    }

    private void NextAction()
    {
        index++;
        if (index >= ImagePaths.Count)
        {
            index = ImagePaths.Count - 1;
        }
        MainPictureBox.Image = Image.FromFile(ImagePaths(index));
        GC.Collect();
    }

    private void SaveButton_Click(object sender, EventArgs e)
    {
        Attribute attribute = new Attribute();
        
        if (radioButton1.Checked)
        {
            attribute.attributeEnum = Attribute.AttributeEnum.Mountain;
        }
        if (radioButton2.Checked)
        {
            attribute.attributeEnum = Attribute.AttributeEnum.Cat;
        }
        MessageBox.Show(attribute.ToString());
        AttributeList.Add(attribute);
        AttributeListToTxt();
        NextAction();
    }

    private void AttributeListToTxt()
    {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < this.AttributeList.Count; i++)
        {
            sb.Append(this.ImagePaths(i) + "t" + this.AttributeList(i).ToString() + Environment.NewLine);
        }
        File.WriteAllText("LabelResult.txt", sb.ToString());
    }
}

All suggestions are welcome.

If there is any possible improvement about:

  • Potential drawback or unnecessary overhead
  • The design of implemented methods

please let me know.

c – Naming convention for functions that mutate arguments vs creating a new object

Take the following signature

BigInt* addBigInt(BigInt* arg1, BigInt* arg2);

Traditionally, the safest way to implement this function would be for it not mutate the arguments, and would necessarily need to create a new object to result for the operation. Alternatively, if the aim is to conserve on system memory, arg1 could be the object that the resulting operation would return having mutated that object.

The question is, is there an established naming convention the would delineate the nuance between the two implementation choices? Or is this something that would need to be clearly laid out in the documentation where the developer is establishing the convention?

Let’s assume this is in C where function overloading is not possible.

2d – Design an object for a unity game?

I’m new to game development, I recently started a new game project. I use the unity engine for game development. Now, what is the best program for object (vehicles, plant, etc) designing? It should be easy to learn and not too complicated. I read about Blender but in my opinion, it’s too complicated.

PS: I only have 2 weeks to learn design. It’s a school project.

object oriented – How could I construct a C# function that takes in a credit limit and advance amount and outputs an Amount and APR?

0

The Amount and APR will be set as a percentage of the credit limit. The split will be 50%, 25%, and 25% of the credit limit compared to the advance amount. APR starts at 249 and increased 25% each time.

For example :

My credit limit is $1000 and my advance amount is $800. My output should be the following:

{ Amount: 500, APR: 249.00 }, 
{ Amount: 250, APR: 311.25 },
{ Amount: 50, APR: 373.50 }`

or

My credit limit is $1000 and my advance amount is $700. My output should be the following:

{ Amount: 500, APR: 249.00 },
{ Amount: 200, APR: 311.25 }

My code works but I know that it is not best practice and would like to be more efficient. I know there is a more mathematical way to get this done it is just not coming to me. Such as the Environment.Exit(-1) should not be used but I needed it otherwise some outputs were incorrect.

My Code:

public static int CreditLimit { get; set; }
        public static int AdvanceAmount { get; set; }
        public static int Amount { get; set; }
        public static int APR { get; set; }

    public Bam(int creditLimit, int advanceAmount, int amount, int apr)
    {
        CreditLimit = creditLimit;
        AdvanceAmount = advanceAmount;
        Amount = amount;
        APR = apr;
    }

    //FIRST AMOUNT CALCULATION

     public decimal EquationForOutput()
    {
        Amount = ((int)(CreditLimit * .5));
        if (AdvanceAmount <= CreditLimit * .5)
        {
            Amount = AdvanceAmount;
            return Amount;
           
        }
        return Amount;
    }



class Program
    {
        static void Main(string() args)
        {
            int amount = 0;
            int apr = 249;

        Console.WriteLine("Enter Credit Limit");
        int creditLimit = (int)Convert.ToInt64(Console.ReadLine());


        Console.WriteLine("Enter Advance Amount");
        int advanceAmount = (int)Convert.ToInt64(Console.ReadLine());

        Bam nums = new Bam(creditLimit, advanceAmount, amount, apr);
        amount = (int)nums.EquationForOutput();

        Console.WriteLine($"Amount: {amount}");
        Console.WriteLine($"APR: {apr}");



        //SECOND AMOUNT AND APR

        var newApr = (apr * .25) + apr;
        if (advanceAmount <= creditLimit * .5)
        {
            Environment.Exit(-1);
        }
        else if (advanceAmount -amount < creditLimit * .25)
        {

            Console.WriteLine($"Amount: {advanceAmount-amount}");
            Console.WriteLine($"APR: {newApr}");

            Environment.Exit(-1);
        }
        
        else
        {
            Console.WriteLine($"Amount: {amount * .5}");
            Console.WriteLine($"APR: {newApr}");
        }


        //THIRD AMOUNT AND APR
        
        int newAmount = (int)(advanceAmount - (creditLimit * .25) + amount) - creditLimit;
        
        bool endTrue = Convert.ToBoolean(newAmount);

        if (endTrue)
        {
            newApr = (apr * .5) + apr;
            Console.WriteLine($"Amount: {(advanceAmount - amount) - amount * .5}");
            Console.WriteLine($"APR: {newApr}");
        }
    }